On Tuesday, December 3, 2013 10:39:00 PM UTC-8, Nels Nelson wrote:
>
> I still can't detect a reason that you would want to do this during
>> after_initialize, unless something_special_with(album) mutates the
>> receiver. Is that the case?
>
>
> I probably don't want to do it during after_initialize, necessarily. I
> just need the custom task to modify Bar, using information from the members
> of foos, whenever a Bar is instantiated with the query results.
>
> Are you saying that something like
>
> class Bar < Sequel::Model
> many_to_many :foos, :after_load => proc do |foo|
> something_special_with(self)
> end
> eager(:foos).all
> end
>
> will do the trick? Isn't the eager(:foos).all statement an explicit
> invocation? I am trying to have foos loaded automatically and implicitly.
>
Yes, the eager(:foos).all expression would just load all bars and their
respective foos, but not do anything with them (unless
something_special_with caches them in some way).
If you always want the foos loaded every time you load the Bar, you could
try:
class Bar < Sequel::Model
many_to_many :foos, :after_load => proc{|bar, foo|
something_special_with(bar, foo)}
plugin :tactical_eager_loading
def after_initialize
foos
end
end
> You probably want to add this after plugin: rcte_tree:
>>
>> one_to_many :children, :clone=>:children, :eager=>:albums
>>
>
> I attempted this, and it results in that "weird error when attempting to
> access a count of the cloned Artist.children association" I was talking
> about.
>
> undefined method `id' for {:count=>10}:Hash
>
> To solve this, I tried to change
>
> jimi.children_dataset.count
>
> to this
>
> jimi.children.count
>
> and that seemed to work, but then when attempting to remove a node from
> the children association
>
> class Bar < Sequel::Model
> def remove
> self.parent.remove_child self
> end
> end
>
> I got another error
>
> undefined method `id' for {:one=>1}:Hash
>
Could you provide a full backtrace for these errors? This looks like the
type of error you would get if you were using eager_graph, but not eager.
> There's always:
>>
>
>> jimi.descendants_dataset.where(...).all
>
>
> I'll give that a shot.
>
> My goodness, this Google WYSIWYG editing is atrocious. The Quote button
> and Undo function are completely broken.
>
I agree, the editing isn't good for anything complex.
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/groups/opt_out.