Class: RailsOptimizer::HasOne

Inherits:
Association show all
Defined in:
lib/rails_optimizer/has_one.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



5
6
7
8
9
# File 'lib/rails_optimizer/has_one.rb', line 5

def self._define(owner, name )
	owner.__send__(:define_method, name) do |*args|
		return RailsOptimizer::HasOne.new(self, name, *args).get_target
	end
end

Instance Method Details

#get_targetObject



11
12
13
14
15
16
17
18
19
# File 'lib/rails_optimizer/has_one.rb', line 11

def get_target
	super do
		if args.empty?
			klass
		else
			klass.select(*args)
		end.execute(&reflection_scope).execute(&finded)
	end
end