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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
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