Class: ActiveRecordExtended::QueryMethods::Unionize::UnionChain

Inherits:
Object
  • Object
show all
Includes:
Utilities::OrderBy, Utilities::Support
Defined in:
lib/active_record_extended/query_methods/unionize.rb

Constant Summary

Constants included from Utilities::Support

Utilities::Support::A_TO_Z_KEYS

Instance Method Summary collapse

Methods included from Utilities::OrderBy

#inline_order_by, #order_by_expression, #process_ordering_arguments!, #scope_preprocess_order_args, #to_ordered_table_path

Methods included from Utilities::Support

#double_quote, #flatten_safely, #flatten_to_sql, #from_clause_constructor, #generate_grouping, #generate_named_function, #group_when_needed, #key_generator, #literal_key, #needs_to_be_grouped?, #nested_alias_escape, #pipe_cte_with!, #to_arel_sql, #wrap_with_agg_array, #wrap_with_array

Constructor Details

#initialize(scope) ⇒ UnionChain

Returns a new instance of UnionChain.



13
14
15
# File 'lib/active_record_extended/query_methods/unionize.rb', line 13

def initialize(scope)
  @scope = scope
end

Instance Method Details

#all(*args) ⇒ Object Also known as: union_all



41
42
43
44
# File 'lib/active_record_extended/query_methods/unionize.rb', line 41

def all(*args)
  append_union_order!(:union_all, args)
  @scope
end

#as(from_clause_name) ⇒ Object Also known as: union_as



17
18
19
20
# File 'lib/active_record_extended/query_methods/unionize.rb', line 17

def as(from_clause_name)
  @scope.unionized_name = from_clause_name.to_s
  @scope
end

#except(*args) ⇒ Object Also known as: union_except



47
48
49
50
# File 'lib/active_record_extended/query_methods/unionize.rb', line 47

def except(*args)
  append_union_order!(:except, args)
  @scope
end

#intersect(*args) ⇒ Object Also known as: union_intersect



53
54
55
56
# File 'lib/active_record_extended/query_methods/unionize.rb', line 53

def intersect(*args)
  append_union_order!(:intersect, args)
  @scope
end

#order(*ordering_args) ⇒ Object Also known as: order_union



23
24
25
26
27
# File 'lib/active_record_extended/query_methods/unionize.rb', line 23

def order(*ordering_args)
  process_ordering_arguments!(ordering_args)
  @scope.union_ordering_values += ordering_args
  @scope
end

#reorder(*ordering_args) ⇒ Object Also known as: reorder_union



30
31
32
33
# File 'lib/active_record_extended/query_methods/unionize.rb', line 30

def reorder(*ordering_args)
  @scope.union_ordering_values.clear
  order(*ordering_args)
end

#union(*args) ⇒ Object



36
37
38
39
# File 'lib/active_record_extended/query_methods/unionize.rb', line 36

def union(*args)
  append_union_order!(:union, args)
  @scope
end