Module: NaranyaEcm::Rest::Associations::ClassMethods

Defined in:
lib/naranya_ecm/rest/associations.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to(name, options = {}) ⇒ Object



133
134
135
# File 'lib/naranya_ecm/rest/associations.rb', line 133

def belongs_to(name, options={})
  associations[name] = BelongsTo.new self, name, options
end

#has_many(name, options = {}) ⇒ Object



125
126
127
# File 'lib/naranya_ecm/rest/associations.rb', line 125

def has_many(name, options={})
  associations[name] = HasMany.new self, name, options
end

#has_one(name, options = {}) ⇒ Object



129
130
131
# File 'lib/naranya_ecm/rest/associations.rb', line 129

def has_one(name, options={})
  associations[name] = HasOne.new self, name, options
end

#is_association?(association_name) ⇒ Boolean

Returns:

  • (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_associationsObject



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