Module: ActiveRecord::QueryMethods
- Defined in:
- lib/left_joins_for_rails_3.rb,
lib/left_joins.rb
Overview
● Implement check_if_method_has_arguments! method for Rails 3
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#left_outer_joins_values ⇒ Object
29
30
31
|
# File 'lib/left_joins.rb', line 29
def left_outer_joins_values
@left_outer_joins_values ||= []
end
|
Instance Method Details
#build_arel(*args) ⇒ Object
53
54
55
56
57
|
# File 'lib/left_joins.rb', line 53
def build_arel(*args)
arel = build_arel_without_outer_joins(*args)
build_left_outer_joins(arel, @left_outer_joins_values) if @left_outer_joins_values
return arel
end
|
#build_arel_without_outer_joins ⇒ Object
52
|
# File 'lib/left_joins.rb', line 52
alias_method :build_arel_without_outer_joins, :build_arel
|
#build_joins(manager, joins, join_type = nil) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/left_joins.rb', line 60
def build_joins(manager, joins, join_type = nil)
Thread.current.thread_variable_set(:left_joins_join_type, join_type)
result = build_joins_without_join_type(manager, joins)
Thread.current.thread_variable_set(:left_joins_join_type, nil)
return result
end
|
#build_joins_without_join_type ⇒ Object
59
|
# File 'lib/left_joins.rb', line 59
alias_method :build_joins_without_join_type, :build_joins
|
#build_left_outer_joins(manager, joins) ⇒ Object
67
68
69
70
|
# File 'lib/left_joins.rb', line 67
def build_left_outer_joins(manager, joins)
result = build_joins(manager, joins, Arel::Nodes::OuterJoin)
return result
end
|
#check_if_method_has_arguments!(method_name, args) ⇒ Object
5
6
7
8
9
|
# File 'lib/left_joins_for_rails_3.rb', line 5
def check_if_method_has_arguments!(method_name, args)
if args.blank?
raise ArgumentError, "The method .#{method_name}() must contain arguments."
end
end
|
#left_outer_joins(*args) ⇒ Object
Also known as:
left_joins
33
34
35
36
37
38
39
40
41
|
# File 'lib/left_joins.rb', line 33
def left_outer_joins(*args)
check_if_method_has_arguments!(:left_outer_joins, args)
args.compact!
args.flatten!
self.distinct_value = false if self.distinct_value == nil
return (LeftJoins::IS_RAILS3_FLAG ? clone : spawn).left_outer_joins!(*args)
end
|
#left_outer_joins!(*args) ⇒ Object
43
44
45
46
|
# File 'lib/left_joins.rb', line 43
def left_outer_joins!(*args)
left_outer_joins_values.concat(args)
self
end
|