Class: RailsOptimizer::Reflection
- Inherits:
-
Object
- Object
- RailsOptimizer::Reflection
- Defined in:
- lib/rails_optimizer/reflection.rb
Instance Attribute Summary collapse
-
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
Instance Method Summary collapse
- #foreign_type ⇒ Object
-
#initialize(owner, name) ⇒ Reflection
constructor
A new instance of Reflection.
- #klass ⇒ Object
- #reflection ⇒ Object
- #scope ⇒ Object
Constructor Details
#initialize(owner, name) ⇒ Reflection
Returns a new instance of Reflection.
5 6 7 8 |
# File 'lib/rails_optimizer/reflection.rb', line 5 def initialize(owner, name) @owner = owner @name = name end |
Instance Attribute Details
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
3 4 5 |
# File 'lib/rails_optimizer/reflection.rb', line 3 def foreign_key @foreign_key end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rails_optimizer/reflection.rb', line 3 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
3 4 5 |
# File 'lib/rails_optimizer/reflection.rb', line 3 def owner @owner end |
Instance Method Details
#foreign_type ⇒ Object
26 27 28 |
# File 'lib/rails_optimizer/reflection.rb', line 26 def foreign_type reflection.foreign_type end |
#klass ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rails_optimizer/reflection.rb', line 10 def klass if reflection.polymorphic? owner.read_attribute(foreign_type).constantize else reflection.klass end end |
#reflection ⇒ Object
22 23 24 |
# File 'lib/rails_optimizer/reflection.rb', line 22 def reflection @reflection ||= owner._reflections[name] end |
#scope ⇒ Object
18 19 20 |
# File 'lib/rails_optimizer/reflection.rb', line 18 def scope reflection.scope end |