Module: Lore::Polymorphic_Class_Methods
- Included in:
- Table_Accessor
- Defined in:
- lib/lore/model/polymorphic.rb
Instance Method Summary collapse
- #is_polymorphic(key = :concrete_model) ⇒ Object
- #is_polymorphic? ⇒ Boolean
- #polymorphic_attribute ⇒ Object
- #polymorphic_attribute_index ⇒ Object
- #select_polymorphic(clause = nil, &block) ⇒ Object
Instance Method Details
#is_polymorphic(key = :concrete_model) ⇒ Object
11 12 13 14 15 |
# File 'lib/lore/model/polymorphic.rb', line 11 def is_polymorphic(key=:concrete_model) @polymorphic_attribute = key.to_sym @polymorphic_attribute_index = get_fields_flat.index(key.to_sym) @is_polymorphic = true end |
#is_polymorphic? ⇒ Boolean
17 18 19 |
# File 'lib/lore/model/polymorphic.rb', line 17 def is_polymorphic? (@is_polymorphic == true) end |
#polymorphic_attribute ⇒ Object
34 35 36 |
# File 'lib/lore/model/polymorphic.rb', line 34 def polymorphic_attribute @polymorphic_attribute end |
#polymorphic_attribute_index ⇒ Object
37 38 39 |
# File 'lib/lore/model/polymorphic.rb', line 37 def polymorphic_attribute_index @polymorphic_attribute_index end |
#select_polymorphic(clause = nil, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lore/model/polymorphic.rb', line 21 def select_polymorphic(clause=nil, &block) base_entities = select(clause, &block) base_entities.map { |e| cmodel = e.get_concrete_model if cmodel then e = cmodel.load(get_fields[table_name].first => e.pkey()) else e = false end e } end |