Class: Masterman::Association
- Inherits:
-
Object
- Object
- Masterman::Association
- Defined in:
- lib/masterman/association.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#reflection ⇒ Object
readonly
Returns the value of attribute reflection.
Instance Method Summary collapse
-
#initialize(model, reflection) ⇒ Association
constructor
A new instance of Association.
- #reader ⇒ Object
Constructor Details
#initialize(model, reflection) ⇒ Association
Returns a new instance of Association.
5 6 7 8 |
# File 'lib/masterman/association.rb', line 5 def initialize(model, reflection) @model = model @reflection = reflection end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/masterman/association.rb', line 3 def model @model end |
#reflection ⇒ Object (readonly)
Returns the value of attribute reflection.
3 4 5 |
# File 'lib/masterman/association.rb', line 3 def reflection @reflection end |
Instance Method Details
#reader ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/masterman/association.rb', line 10 def reader result = read_reflection if result && reflection.scope Array.wrap(result).select do |record| record.instance_exec(&reflection.scope) end else result end end |