That makes sense.  Thank you, Jeremy!
-Nels

On Sunday, January 22, 2017 at 6:35:05 PM UTC-6, Jeremy Evans wrote:
>
> On Sunday, January 22, 2017 at 3:36:07 PM UTC-8, Nels Nelson wrote:
>>
>> Greetings, forum,-
>>
>> Quick question: is there any equivalent for ActiveRecord's 
>> Persistence#becomes method for use with the single_table_inheritance plugin?
>>
>> ActiveRecord source code reference: 
>> https://github.com/rails/rails/blob/75f274c8e42e9 
>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Frails%2Frails%2Fblob%2F75f274c8e42e9df3eeebb557583e1aafd2396047%2Factiverecord%2Flib%2Factive_record%2Fpersistence.rb%23L212&sa=D&sntz=1&usg=AFQjCNEyUrjC4C6IM6YlEF64dzFuTyj0NQ>
>>
>>
>>
>> df3eeebb557583e1aafd2396047/activerecord/lib/active_record/persistence.rb#L212
>>  
>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Frails%2Frails%2Fblob%2F75f274c8e42e9df3eeebb557583e1aafd2396047%2Factiverecord%2Flib%2Factive_record%2Fpersistence.rb%23L212&sa=D&sntz=1&usg=AFQjCNEyUrjC4C6IM6YlEF64dzFuTyj0NQ>
>>
>> Basically, I'd just like to update an object's object_type sti field 
>> during runtime and be able to run its initialization so it can run some 
>> validations, but that doesn't seem quite doable with the version of Sequel 
>> 4.17.0 I have installed at the moment.
>>
>> Best regards,
>> -Nels Nelson
>>
>
> Sequel doesn't have an equivalent method. Maybe you can add something like:
>
> def becomes(klass)
>   new? ? klass.new(values) : klass.load(values)
> end
>
> You may want to add additional code if you want to handle other cases 
> other than basic ones.  But this is not an API I want to support in Sequel.
>
> 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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to