Module: ActiveScaffold::OuterJoins

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_scaffold/extensions/left_outer_joins.rb

Instance Method Summary collapse

Instance Method Details

#build_arelObject


28
29
30
31
32
33
34
35
36
# File 'lib/active_scaffold/extensions/left_outer_joins.rb', line 28

def build_arel
  if left_outer_joins_values.empty?
    super
  else
    relation = except(:left_outer_joins)
    relation.joins! ActiveRecord::Associations::JoinDependency.new(@klass, left_outer_joins_values, [])
    relation.build_arel
  end
end

#left_outer_joins(*args) ⇒ Object Also known as: left_joins


15
16
17
18
# File 'lib/active_scaffold/extensions/left_outer_joins.rb', line 15

def left_outer_joins(*args)
  check_if_method_has_arguments!('left_outer_joins', args)
  spawn.left_outer_joins!(*args.compact.flatten)
end

#left_outer_joins!(*args) ⇒ Object Also known as: left_joins!


21
22
23
24
25
# File 'lib/active_scaffold/extensions/left_outer_joins.rb', line 21

def left_outer_joins!(*args)
  self.joins_values += [''] # HACK: for using left_outer_joins in update_all/delete_all
  self.left_outer_joins_values += args
  self
end

#left_outer_joins_valuesObject


6
7
8
# File 'lib/active_scaffold/extensions/left_outer_joins.rb', line 6

def left_outer_joins_values
  @values[:left_outer_joins] || []
end

#left_outer_joins_values=(values) ⇒ Object

Raises:

  • (ImmutableRelation)

10
11
12
13
# File 'lib/active_scaffold/extensions/left_outer_joins.rb', line 10

def left_outer_joins_values=(values)
  raise ImmutableRelation if @loaded
  @values[:left_outer_joins] = values
end