Got it, will send a PR if it continues to be a problem.

On Sunday, June 28, 2020 at 7:35:47 PM UTC+3, Jeremy Evans wrote:
>
> On Sunday, June 28, 2020 at 7:28:37 AM UTC-7, Aryk Grosz wrote:
>>
>> Currently for the composition plugin, if you set a composed argument, it 
>> will not get decomposed until before_validation:
>>
>> def before_validation
>>   # decomposer_method is private
>>   @compositions.keys.each{|n| 
>> send(model.compositions[n][:decomposer_method])} if @compositions
>>   super
>> end
>>
>>
>> Any reason this is hard coded in place?
>>
>> If you use FactoryBot for instance, and you want to do 
>> build(:record_name), the composed fields will not be decomposed into their 
>> attributes unless you just randomly run "valid?" on it.
>>
>
> save runs validation hooks by default, so assuming it runs save, 
> decomposition should also happen then.  Not sure what FactoryBot does when 
> you run build.  In general you only need to decompose attributes when 
> saving, there is no need if you are not saving.  Unless you are doing 
> something like also checking the decomposed values (in which case, why use 
> a composition)?
>  
>
>> Seems like there should be a way to call it ahead of time if needed or 
>> change where it happens.
>>
>> Maybe a "decompose_compositions" function that one could call directly?
>>
>
> Sure, it's possible to extract a method for reuse, it's just that nobody 
> has asked for it yet.  Feel free to send in a pull request with specs if 
> you would like it extracted.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/849dff74-7d29-4ea8-bf6a-bddc8ec40469o%40googlegroups.com.

Reply via email to