Module: AssociationWithOperator
- Defined in:
- lib/association_with_operator.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/association_with_operator.rb', line 14
def method_missing(method, *args)
results = super
unless ActiveRecord::NamedScope::Scope === results
if results.respond_to?(:operator=)
results.operator= proxy_owner.operator
elsif results.kind_of? Array
results.each{|r| r.operator = proxy_owner.operator if r.respond_to?(:operator=)}
end
end
results
end
|
Instance Method Details
#construct_join_attributes(associate) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/association_with_operator.rb', line 26
def construct_join_attributes(associate)
join_attributes = super
if @owner.operator || associate.operator
join_attributes[:operator] ||= @owner.operator
join_attributes[:operator] ||= associate.operator
end
join_attributes
end
|
#find(*args) ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'lib/association_with_operator.rb', line 3
def find(*args)
results = super
if results.kind_of? Array
results.each{|r| r.operator = proxy_owner.operator}
else
results.operator = proxy_owner.operator if results
end
results
end
|