Module: SmoothOperator::Relation::Associations

Included in:
Base
Defined in:
lib/smooth_operator/relation/associations.rb

Instance Method Summary collapse

Instance Method Details

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



16
17
18
# File 'lib/smooth_operator/relation/associations.rb', line 16

def belongs_to(nested_object_name, options = {})
  accepts_nested_objects(nested_object_name, :belongs_to, options)
end

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



8
9
10
# File 'lib/smooth_operator/relation/associations.rb', line 8

def has_many(nested_object_name, options = {})
  accepts_nested_objects(nested_object_name, :has_many, options)
end

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



12
13
14
# File 'lib/smooth_operator/relation/associations.rb', line 12

def has_one(nested_object_name, options = {})
  accepts_nested_objects(nested_object_name, :has_one, options)
end

#reflect_on_all_associations(macro = nil) ⇒ Object



28
29
30
# File 'lib/smooth_operator/relation/associations.rb', line 28

def reflect_on_all_associations(macro = nil)
  macro ? reflections.values.select { |reflection| reflection.macro == macro } : reflections.values
end

#reflect_on_association(association) ⇒ Object



24
25
26
# File 'lib/smooth_operator/relation/associations.rb', line 24

def reflect_on_association(association)
  reflections[association]
end

#reflectionsObject



20
21
22
# File 'lib/smooth_operator/relation/associations.rb', line 20

def reflections
  Helpers.get_instance_variable(self, :reflections, {})
end