On Tuesday, December 25, 2018 at 8:50:32 AM UTC-8, genc wrote:
>
> Hi Jeremy,
>
> I have models like this:
>
>
> class Mailbox::Email < Mailbox::Model(:emails)
> end
> class Mailbox::Post < Mailbox::Model(:emails)
> end
>
>
> and of course a base class:
>
> module Mailbox
> def self.Model(source)
> c = Sequel::Model(second_db)
> c.set_dataset(source)
> end
>
> # defining admin? here not work as its inhertied from Model.
> end
>
You want to use Class.new(Sequel::Model) to create the abstract base class,
and def_Model to define the appropriate model method. Then you can use
class_eval do define the methods shared by subclasses:
module Mailbox
Model = Class.new(Sequel::Model)
Model.def_Model(self)
Model.class_eval do
def admin?
is_admin || false
end
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.