Module: NaranyaEcm::Rest::Associations::ClassMethods
- Defined in:
- lib/naranya_ecm/rest/associations.rb
Instance Method Summary collapse
- #belongs_to(name, options = {}) ⇒ Object
- #has_many(name, options = {}) ⇒ Object
- #has_one(name, options = {}) ⇒ Object
- #is_association?(association_name) ⇒ Boolean
- #reflect_on_all_associations ⇒ Object
- #reflect_on_association(association_name) ⇒ Object
Instance Method Details
#belongs_to(name, options = {}) ⇒ Object
133 134 135 |
# File 'lib/naranya_ecm/rest/associations.rb', line 133 def belongs_to(name, ={}) associations[name] = BelongsTo.new self, name, end |
#has_many(name, options = {}) ⇒ Object
125 126 127 |
# File 'lib/naranya_ecm/rest/associations.rb', line 125 def has_many(name, ={}) associations[name] = HasMany.new self, name, end |
#has_one(name, options = {}) ⇒ Object
129 130 131 |
# File 'lib/naranya_ecm/rest/associations.rb', line 129 def has_one(name, ={}) associations[name] = HasOne.new self, name, end |
#is_association?(association_name) ⇒ Boolean
121 122 123 |
# File 'lib/naranya_ecm/rest/associations.rb', line 121 def is_association?(association_name) associations.has_key? association_name end |
#reflect_on_all_associations ⇒ Object
142 143 144 |
# File 'lib/naranya_ecm/rest/associations.rb', line 142 def reflect_on_all_associations associations end |
#reflect_on_association(association_name) ⇒ Object
137 138 139 140 |
# File 'lib/naranya_ecm/rest/associations.rb', line 137 def reflect_on_association(association_name) raise "Association #{name} does not exist" unless is_association? association_name associations[association_name] end |