-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add Box#build #34
Comments
For anyone looking to take this on, you can start here: https://github.com/luckyframework/avram/blob/master/spec/support/base_box.cr and https://github.com/luckyframework/avram/blob/master/spec/support/boxes/user_box.cr#L8 These are examples that already do this. Just make it native. |
I think what build would do is manually set the id. I'm not 100% sure the best way to do this but open to PRs to see what people think of |
Started working on this, but then got blocked. The current idea of the Avram model is that it's a representation of data from a database. @matthewmcgarvey brought up the point that this idea would break that convention. Aside from that, just from a technical aspect, we now have Here's an example of how this idea was originally used: # Taken from Avram specs
it "returns the value from params for updates" do
user = UserFactory.build
params = {"name" => "New Name From Params"}
avram_params = Avram::Params.new(params)
operation = SaveUser.new(user, avram_params)
operation.name.value.should eq params["name"]
operation.nickname.value.should eq user.nickname
operation.age.value.should eq user.age
end Where the idea here is that you're testing the SaveOperation, but have no need for the data to be persisted. This idea may just be an internal "hack" to allow us to test some internals. I'm not sure that a standard user of Avram would need to do this. For now, I'm going put this PR on hold, but if anyone has another real-world example of where this could be helpful, please put your example here and we can revisit it. |
After some thought, I've decided to close out this feature request. You can actually just call |
Make it so that you can generate an unpersisted model from the form fields
The text was updated successfully, but these errors were encountered: