Class: RailsOptimizer::BelongsTo
- Inherits:
-
Association
- Object
- Association
- RailsOptimizer::BelongsTo
- Defined in:
- lib/rails_optimizer/belongs_to.rb
Instance Attribute Summary
Attributes inherited from Association
#args, #klass, #name, #owner, #reflection
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Association
#initialize, #reflection_scope
Constructor Details
This class inherits a constructor from RailsOptimizer::Association
Class Method Details
._define(owner, name) ⇒ Object
4 5 6 7 8 |
# File 'lib/rails_optimizer/belongs_to.rb', line 4 def self._define(owner, name ) owner.__send__(:define_method, name) do |*args| return RailsOptimizer::BelongsTo.new(self, name, *args).get_target end end |
Instance Method Details
#get_target ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rails_optimizer/belongs_to.rb', line 10 def get_target super do if args.empty? klass else klass.select(*args) end .execute(&reflection_scope) .execute(&finded) end end |