I'm having trouble with #with_extend.

I can extend methods from another module but I cannot continue chaining for 
example association join.

class Garage < Sequel::Model

one_to_many :cars

end


class Car < Sequel::Model

one_to_many :seats

module Foo
  def steer_car
    association_join(:seats)
  end
end
dataset_extend Foo

end

garage.association_join(:cars).with_extend(Car::Foo).steer_car # -> this 
will give an error because association_join still thinks we are in Garage 
model and there is no :seats association in Garage.



On Tuesday, June 16, 2020 at 3:10:05 PM UTC+3, Aryk Grosz wrote:
>
> Got it, ok will try that!
>
> On Tuesday, June 9, 2020 at 7:24:49 PM UTC+3, Jeremy Evans wrote:
>>
>> On Tuesday, June 9, 2020 at 8:52:41 AM UTC-7, Aryk Grosz wrote:
>>>
>>> So you mean to use #extend on the instance of the dataset?
>>>
>>
>> More or less that's what dataset_module ends up using.  It actually uses 
>> Dataset#with_extend.  You can't use Dataset#extend directly as datasets are 
>> frozen (at least in Ruby 2.4+).
>>
>> 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/858977ee-efa8-4e66-9e44-01f0ab609baeo%40googlegroups.com.

Reply via email to