Module: ActiveRecord::ActsAsEntity::ClassMethods

Defined in:
lib/acts_as_entity/base.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_entity(entityDef, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/acts_as_entity/base.rb', line 11

def acts_as_entity(entityDef,options = {})
  after_initialize :setAttrs
  class << self
    alias_method :find_entities, :find#tester avec self??
  end
  include ActiveRecord::ActsAsEntity::InstanceMethods

  # create new class methods
  instance_eval <<-DEFINE_METHODS
    public
    def find(args)
      find_entities(args, :conditions =>  "entity_def_id = '#{entityDef}' ")
    end
    def all
      find_entities(:all, :conditions =>  "entity_def_id = '#{entityDef}' " )
    end
  DEFINE_METHODS
end