On Monday, June 12, 2017 at 8:27:05 AM UTC-7, binarypaladin wrote:
>
> Let's say I'm using naming conventions that are very different than the 
> norm but it still follows a naming pattern that could infer defaults.
>
> So, instead of something like:
>
> /models/resource.rb -> Resource
> /models/thing.rb -> Thing
>
> It is more like:
>
> /resource/model.rb -> Resource::Model
> /thing/model.rb -> Thing::Model
>
> I still know the name well enough to infer the defaults, albeit a little 
> differently than it currently does. Is there a proc somewhere I override or 
> do I need to whip up a plugin that does that?
>
> I was looking through the associations code and 
> in Sequel::Model::Associations::ClassMethods#associate I found 
> "late_binding_class_option" which seems like it was where I should be 
> looking, but didn't see anything to indicate I could override the behavior. 
> Then, of course, introspecting the keys gets messy too since it thinks 
> "model_id" is the answer to everything.
>

I think in a case like this, you are better off just specifying 
:class=>"Resource::Model" or similar for each association, as opposed to 
trying to change the default.  However, one way to handle this may be:

class Sequel::Model
  def self.associate(type, name, opts={})
    opts = opts.merge(:class=>"#{camelize(name)}::Model") unless 
opts[:class]
    super
  end
end

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