Class: Colonization::ModelRelation

Inherits:
ModelEntity show all
Defined in:
lib/colonization/model_relation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reflection, strategy) ⇒ ModelRelation

Returns a new instance of ModelRelation.



9
10
11
12
# File 'lib/colonization/model_relation.rb', line 9

def initialize(reflection, strategy)
  @reflection = reflection
  @strategy = strategy || {}
end

Instance Attribute Details

#reflectionObject

Returns the value of attribute reflection.



7
8
9
# File 'lib/colonization/model_relation.rb', line 7

def reflection
  @reflection
end

#strategyObject

Returns the value of attribute strategy.



7
8
9
# File 'lib/colonization/model_relation.rb', line 7

def strategy
  @strategy
end

Instance Method Details

#nameObject



14
15
16
# File 'lib/colonization/model_relation.rb', line 14

def name
  reflection.name
end

#valueObject



18
19
20
21
22
23
24
# File 'lib/colonization/model_relation.rb', line 18

def value
  if strategy == :fixed #TODO: refactor this shit
    generate_relation_value_with_fixed_strategy
  else
    generate_relation_value_with_default_strategy
  end
end