Module: DynamicActiveResource::Associations

Defined in:
lib/dynamic_active_resource/associations.rb,
lib/dynamic_active_resource/associations/base.rb,
lib/dynamic_active_resource/associations/has_many.rb,
lib/dynamic_active_resource/associations/belongs_to.rb

Defined Under Namespace

Classes: Base, BelongsTo, HasMany

Instance Method Summary collapse

Instance Method Details

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



14
15
16
17
18
19
# File 'lib/dynamic_active_resource/associations.rb', line 14

def belongs_to(association_sym, options = {})
  b_t_association = BelongsTo.new(association_sym, options)
  associations = self.instance_variable_get(:@associations) || []
  associations << b_t_association
  self.instance_variable_set(:@associations, associations)
end

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



7
8
9
10
11
12
# File 'lib/dynamic_active_resource/associations.rb', line 7

def has_many(assosiation_sym, options = {})
  h_m_association = HasMany.new(assosiation_sym, options)
  associations = self.instance_variable_get(:@associations) || []
  associations << h_m_association
  self.instance_variable_set(:@associations, associations)
end