Module: Rea::MetaType::Entity::ClassMethods
- Defined in:
- lib/rea/meta_type/entity.rb
Instance Method Summary collapse
- #group_item(*group_names, &block) ⇒ Object
- #grouping(options = {}, &block) ⇒ Object
- #item(name, options = {}, &block) ⇒ Object
- #specification(name, options = {}) ⇒ Object
Instance Method Details
#group_item(*group_names, &block) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rea/meta_type/entity.rb', line 35 def group_item *group_names, &block = group_names. group_names.flatten.each do |name| @context = Rea::Group.groups(self).find_or_create_by_name(name, :entity_types=>self.name) block.call if block_given? end end |
#grouping(options = {}, &block) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rea/meta_type/entity.rb', line 28 def grouping ={}, &block has_many :group_entities, :as=>:entity has_many :groups, :through=>:group_entities #group_class.entity_classes << self block.call if block_given? end |
#item(name, options = {}, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rea/meta_type/entity.rb', line 17 def item name, ={}, &block if self.ancestors.include?(ActiveRecord::Base) @context = self.find_or_create_by_name name, else cattr_reader name @context = self.new({:name=>name.to_s, :value=>1}.merge()) self.class_variable_set "@@#{name}", @context end block.call if block_given? end |
#specification(name, options = {}) ⇒ Object
44 45 46 |
# File 'lib/rea/meta_type/entity.rb', line 44 def specification name, ={} belongs_to name, end |