On Monday, June 29, 2020 at 1:27:31 PM UTC-7, lkfken wrote:
>
> module HSP
>   raise NotImplementedError, "HSP database connection is not defined!" unless 
> defined?(::HSP::DB)
>
>   Model = Class.new(Sequel::Model)
>
>   Model.def_Model(self)
>
>   Model.db = ::HSP::DB
>   raise 'connection failed!' unless Model.db.test_connection
>
>     # prefer dynamically loaded instead of always pre-loaded
>     # HSP::Model.plugin :dataset_associations
> end
>
>
>
>
>
> If I want to use the plugin at later time (hot-plug?), it would give me an 
> error
>
> HSP::Model.plugin :dataset_associations
>
> NoMethodError: undefined method `foo' for #<#<Class:0x63648ee9>:0x2ed3b1f5>
>
> The only way I can use the plugin is by always pre-loaded the plugin.
>
>
> How can I make HSP::Model behave similar to Sequel::Model so that I could 
> add plugin dynamically?
>
> thank you.
>
>
Some plugins require that you load them in a parent class before creating 
subclasses.  If you want to load it after creating subclasses, you need to 
add it to each subclass individually instead of the parent class.  If this 
is problematic for you, consider using the subclasses plugin to make it 
easier.

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/46231812-06b5-46dc-9509-6ac83c457c0do%40googlegroups.com.

Reply via email to