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
- #build_arel(*args) ⇒ Object
- #build_arel_without_outer_joins ⇒ Object
- #build_joins(manager, joins, join_type = nil) ⇒ Object
- #build_joins_without_join_type ⇒ Object
- #build_left_outer_joins(manager, joins) ⇒ Object
- #check_if_method_has_arguments!(method_name, args) ⇒ Object
- #left_outer_joins(*args) ⇒ Object (also: #left_joins)
- #left_outer_joins!(*args) ⇒ Object
Instance Attribute Details
#left_outer_joins_values ⇒ Object
16 17 18 |
# File 'lib/left_joins.rb', line 16 def left_outer_joins_values @left_outer_joins_values ||= [] end |
Instance Method Details
#build_arel(*args) ⇒ Object
40 41 42 43 44 |
# File 'lib/left_joins.rb', line 40 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
39 |
# File 'lib/left_joins.rb', line 39 alias_method :build_arel_without_outer_joins, :build_arel |
#build_joins(manager, joins, join_type = nil) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/left_joins.rb', line 47 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
46 |
# File 'lib/left_joins.rb', line 46 alias_method :build_joins_without_join_type, :build_joins |
#build_left_outer_joins(manager, joins) ⇒ Object
54 55 56 57 |
# File 'lib/left_joins.rb', line 54 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
20 21 22 23 24 25 26 27 28 |
# File 'lib/left_joins.rb', line 20 def left_outer_joins(*args) check_if_method_has_arguments!(:left_outer_joins, args) args.compact! args.flatten! self.distinct_value = false return (LeftJoins::IS_RAILS3_FLAG ? clone : spawn).left_outer_joins!(*args) end |
#left_outer_joins!(*args) ⇒ Object
30 31 32 33 |
# File 'lib/left_joins.rb', line 30 def left_outer_joins!(*args) left_outer_joins_values.concat(args) self end |