Class: RailsOptimizer::Association
- Inherits:
-
Object
- Object
- RailsOptimizer::Association
- Defined in:
- lib/rails_optimizer/association.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#reflection ⇒ Object
Returns the value of attribute reflection.
Instance Method Summary collapse
- #get_target ⇒ Object
-
#initialize(owner, name, *args) ⇒ Association
constructor
A new instance of Association.
- #reflection_scope ⇒ Object
Constructor Details
#initialize(owner, name, *args) ⇒ Association
Returns a new instance of Association.
5 6 7 8 9 |
# File 'lib/rails_optimizer/association.rb', line 5 def initialize(owner, name, *args) @owner = owner @name = name.to_s @args = *args end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
3 4 5 |
# File 'lib/rails_optimizer/association.rb', line 3 def args @args end |
#klass ⇒ Object
Returns the value of attribute klass.
3 4 5 |
# File 'lib/rails_optimizer/association.rb', line 3 def klass @klass end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rails_optimizer/association.rb', line 3 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
3 4 5 |
# File 'lib/rails_optimizer/association.rb', line 3 def owner @owner end |
#reflection ⇒ Object
Returns the value of attribute reflection.
3 4 5 |
# File 'lib/rails_optimizer/association.rb', line 3 def reflection @reflection end |
Instance Method Details
#get_target ⇒ Object
23 24 25 26 |
# File 'lib/rails_optimizer/association.rb', line 23 def get_target return owner.association(name.to_sym).target if owner.association(name.to_sym).loaded? yield if block_given? end |
#reflection_scope ⇒ Object
19 20 21 |
# File 'lib/rails_optimizer/association.rb', line 19 def reflection_scope reflection.scope end |