-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple way to "copy" args #19
Comments
I was thinking about this and what we discussed on chat about the Instead of assuming sumac will call a setter that will know how to build a Validation does this already I guess, it's just a question of giving When copying, it would be the same thing, copying would eventually call the On Fri, Dec 27, 2013 at 8:22 PM, imranr [email protected] wrote:
|
I don't see a simple way to do that, which doesn't end up requiring the user to do a bunch of boilerplate. Eg., you could have a But maybe you had something else in mind? maybe a little code example would help me to understand ... |
I was thinking of something like this: trait DbArgs{
var user: String = _
var password: String = _
var host: String = _
var port: Int = _
var connection: Option[Connection] = None
@Constructor
private def build() {
_connection = Try{DB.openConnection(host, port, password, user)} toOption
}
} When sumac is done parsing, validating and setting the vars, it calls the method in the object that is tagged with |
I am totally confused ... how does this solve the copying problem? it seems like it would create another connection, as opposed to copying the existing one. as for solving the initialization problem -- functionally you are proposing two-stage validation, but with some syntax to guide the user on how they should use the different stages, right? I wonder if two stages actually solve the problem, or if it just kicks it down the road a little further. maybe we need some way to define an order for validation, but I can't think of any nice syntax for that ... |
Sumac should provide some simple way to copy "matching" args from one arg instance to another. This should also handle dervied values, not just the direct string arguments. eg.:
when that is copied, it should somehow know that it should also copy
_connection
.I have no idea how to do this right now. maybe it will require extra annotations on
_connection
, or implementing some method which returns some kind of handle on_connection
, I dunno ...The text was updated successfully, but these errors were encountered: