On Tuesday, August 19, 2014 6:04:48 AM UTC-7, [email protected] wrote:
>
> Hi everybody.
>
> I am using ClassTableInheritance and have little doubt about subclasses
> values. From documentation example in
> http://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/ClassTableInheritance.html,
>
> if I acces first Employee with
>
> e = Employee.first
> e.class # => Manager
> e.values # => {:id => 1, :name => 'Buff', :kind => 'Manager'}
>
> How can I access all instance values transparently. Something like:
>
> e.all_values # => {:id => 1, :name => 'Buf', :kind => 'Manager',
> :num_staff => 3}
>
> And why that is not default behaviour for "values" method?
>
values shows you what is currently in the values hash. As you used
Employee for the initial load, it will contain only columns in the
employees table. For the other values, you call the method, and the method
will load the value:
e.num_staff #=> 3
If you want to populate the values for all columns:
e.class.columns.each{|c| e.send(c)}
e.values
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.