Right, pretty much that's what I have done and yes, looks like it's gonna be using Model.class_eval in this approach then (rather than having an abstract base class that doesn't map to any table and is able to define common methods). Though instead of putting in initializer, I have the path app/model/db1 in autoload_paths and define the Model in app/model/db1/db1.rb. I guess I was hoping for the same simple OOP approach (Secretly, I was hoping for a way to still easily swap in " < ActiveRecord::Base" or " < Sequel::Model" in Db1::Base definition -- great plug and play), but this alternative approach works, too, and isn't too bad.
Thanks! Philip > Um, Sequel already handles that case just fine. :) Maybe this is a > simple solution for what you want. In your environment/initializer: > > module Db1 > Model = Sequel::Model(Sequel.connect(...)) > end > > In your model file: > > module Db1 > class A < Model > end > end > > For additional configuration, you could also use Model.class_eval in > the environment/initializer. That should give you all the flexibility > you require. On Oct 13, 2:48 pm, Jeremy Evans <[email protected]> wrote: > On Oct 13, 1:13 pm, philip <[email protected]> wrote: > > > I would love to be able to use the similar subclassing from Base > > approach as I did in AR, as that makes codebase more nimble and > > flexible down the road (e.g. common methods can all be in Base). > > Note that if classes need to share behavior, they can always use the > same plugins or modules instead of an artificial class inheritance > hierarchy. > > > I > > think the only mechanism missing in Sequel is a similar > > "abstract_class = true" -- I know from Sequel documentation that > > Sequel omits this because of a different way of handling STI and > > inheritance. > > Correct, Sequel uses the single_table_inheritance plugin for STI. > Sequel isn't missing "abstract_class = true", that's Sequel's default > behavior. So pretty much anything you would want to do in AR with > "abstract_class = true", you can do in Sequel. > > > But I guess Sequel didn't get to think of this use case > > where abstract_class can work out great in helping refactoring (?). > > It's a simple thing to add, I would imagine, and the value is great. > > So just my feedback. ;) > > Um, Sequel already handles that case just fine. :) Maybe this is a > simple solution for what you want. In your environment/initializer: > > module Db1 > Model = Sequel::Model(Sequel.connect(...)) > end > > In your model file: > > module Db1 > class A < Model > end > end > > For additional configuration, you could also use Model.class_eval in > the environment/initializer. That should give you all the flexibility > you require. > > Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
