Thanks Jeremy. It works like a charm. I just able to inject connection. I was missing one line :)
On Tuesday, December 25, 2018 at 7:50:32 PM UTC+3, 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 > > > Now, on each model I put a method > > > class Mailbox::Email < Mailbox::Model(:emails) > def admin? > is_admin || false > end > end > > > class Mailbox::Post < Mailbox::Model(:posts) > def admin? > is_admin || false > end > end > > > Now, what I am trying to do is remove duplicate code and make each model > get admin method from parent and inherit. So whatever I fetch data i always > have *admin? *method available for each model > > How can I inject this method to base class? Because putting it under > Mailbox does not work. > > What I tried so far: > > define_method :admin? do > 'gencer' > end # inside of Model. > > def admin? > 'gencer' > end # Inside of Mailbox > > > Without luck. > > I want to each method process info for its own model but method should be > global. > > Thanks, > Gencer. > > -- 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.
