lib/left_joins.rb in left_joins-1.0.4 vs lib/left_joins.rb in left_joins-1.0.5
- old
+ new
@@ -10,11 +10,15 @@
module ActiveRecord::QueryMethods
if not method_defined?(:left_outer_joins!)
# ----------------------------------------------------------------
# ● Storing left joins values into @left_outer_joins_values
# ----------------------------------------------------------------
- attr_accessor :left_outer_joins_values
+ attr_writer :left_outer_joins_values
+ def left_outer_joins_values
+ @left_outer_joins_values ||= []
+ end
+
def left_outer_joins(*args)
check_if_method_has_arguments!(:left_outer_joins, args)
args.compact!
args.flatten!
@@ -22,21 +26,21 @@
return (LeftJoins::IS_RAILS3_FLAG ? clone : spawn).left_outer_joins!(*args)
end
def left_outer_joins!(*args)
- (@left_outer_joins_values ||= []) << args
+ left_outer_joins_values.concat(args)
self
end
# ----------------------------------------------------------------
# ● Implement left joins when building arel
# ----------------------------------------------------------------
alias_method :left_joins, :left_outer_joins
alias_method :build_arel_without_outer_joins, :build_arel
def build_arel(*args)
arel = build_arel_without_outer_joins(*args)
- build_left_outer_joins(arel, @left_outer_joins_values.flatten) if @left_outer_joins_values
+ build_left_outer_joins(arel, @left_outer_joins_values) if @left_outer_joins_values
return arel
end
alias_method :build_joins_without_join_type, :build_joins
def build_joins(manager, joins, join_type = nil)