Class: Reactive::MetaModel::Model
- Defined in:
- lib/reactive-core/meta_model.rb
Instance Method Summary collapse
-
#add_observer(object) ⇒ Object
registers the passed object as an observer.
- #associations ⇒ Object
- #attribute(name) ⇒ Object
- #attributes ⇒ Object
- #belong_tos ⇒ Object
- #columns ⇒ Object
- #cooked_attributes ⇒ Object
-
#delete_observer(object) ⇒ Object
remove the object from the registered observers.
- #has_manys ⇒ Object
- #has_ones ⇒ Object
Instance Method Details
#add_observer(object) ⇒ Object
registers the passed object as an observer. the object may receive notification through these methods:
(see ActiveRecord::Callbacks)
Note that each of these methods will receive a unique argument which is the record that has been treated.
49 50 |
# File 'lib/reactive-core/meta_model.rb', line 49 def add_observer(object) end |
#associations ⇒ Object
68 69 70 |
# File 'lib/reactive-core/meta_model.rb', line 68 def associations @attributes.select {|name,value| value.is_a? Association} end |
#attribute(name) ⇒ Object
80 81 82 |
# File 'lib/reactive-core/meta_model.rb', line 80 def attribute(name) @attributes[name.to_sym] end |
#attributes ⇒ Object
76 77 78 |
# File 'lib/reactive-core/meta_model.rb', line 76 def attributes @attributes.values end |
#belong_tos ⇒ Object
64 65 66 |
# File 'lib/reactive-core/meta_model.rb', line 64 def belong_tos @attributes.select {|name,value| value.is_a?(Association) && value.kind == :belongs_to} end |
#columns ⇒ Object
72 73 74 |
# File 'lib/reactive-core/meta_model.rb', line 72 def columns @attributes.select {|name,value| value.is_a? Column} end |
#cooked_attributes ⇒ Object
84 85 86 87 |
# File 'lib/reactive-core/meta_model.rb', line 84 def cooked_attributes association_columns = associations.collect {|assoc| assoc.columns}.flatten associations + columns.reject {|col| association_columns.include?(col.name) || col.primary? } end |
#delete_observer(object) ⇒ Object
remove the object from the registered observers
53 54 |
# File 'lib/reactive-core/meta_model.rb', line 53 def delete_observer(object) end |
#has_manys ⇒ Object
56 57 58 |
# File 'lib/reactive-core/meta_model.rb', line 56 def has_manys @attributes.select {|name,value| value.is_a?(Association) && value.kind == :has_many} end |
#has_ones ⇒ Object
60 61 62 |
# File 'lib/reactive-core/meta_model.rb', line 60 def has_ones @attributes.select {|name,value| value.is_a?(Association) && value.kind == :has_one} end |