Module: Perry::QueryMethods

Defined in:
lib/perry/relation/query_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#from_valueObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def from_value
  @from_value
end

#group_valuesObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def group_values
  @group_values
end

#having_valuesObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def having_values
  @having_values
end

#includes_valueObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def includes_value
  @includes_value
end

#joins_valuesObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def joins_values
  @joins_values
end

#limit_valueObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def limit_value
  @limit_value
end

#offset_valueObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def offset_value
  @offset_value
end

#order_valuesObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def order_values
  @order_values
end

#raw_sql_valueObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def raw_sql_value
  @raw_sql_value
end

#select_valuesObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def select_values
  @select_values
end

#where_valuesObject

TRP: Define each of the variables the query options will be stored in.



3
4
5
# File 'lib/perry/relation/query_methods.rb', line 3

def where_values
  @where_values
end

Instance Method Details

#from(table) ⇒ Object



47
48
49
# File 'lib/perry/relation/query_methods.rb', line 47

def from(table)
  clone.tap { |r| r.from_value = table }
end

#group(*args) ⇒ Object



14
15
16
# File 'lib/perry/relation/query_methods.rb', line 14

def group(*args)
  clone.tap { |r| r.group_values += args if args_valid? args }
end

#having(*args) ⇒ Object



35
36
37
# File 'lib/perry/relation/query_methods.rb', line 35

def having(*args)
  clone.tap { |r| r.having_values += args if args_valid? args }
end

#includes(*args) ⇒ Object



26
27
28
29
# File 'lib/perry/relation/query_methods.rb', line 26

def includes(*args)
  args.reject! { |a| a.nil? }
  clone.tap { |r| r.includes_value = (r.includes_value || {}).deep_merge(sanitize_includes(args)) if args_valid? args }
end

#joins(*args) ⇒ Object



22
23
24
# File 'lib/perry/relation/query_methods.rb', line 22

def joins(*args)
  clone.tap { |r| r.joins_values += args if args_valid?(args) }
end

#limit(value = true) ⇒ Object



39
40
41
# File 'lib/perry/relation/query_methods.rb', line 39

def limit(value = true)
  clone.tap { |r| r.limit_value = value }
end

#offset(value = true) ⇒ Object



43
44
45
# File 'lib/perry/relation/query_methods.rb', line 43

def offset(value = true)
  clone.tap { |r| r.offset_value = value }
end

#order(*args) ⇒ Object



18
19
20
# File 'lib/perry/relation/query_methods.rb', line 18

def order(*args)
  clone.tap { |r| r.order_values += args if args_valid? args }
end

#select(*args) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/perry/relation/query_methods.rb', line 6

def select(*args)
  if block_given?
    to_a.select {|*block_args| yield(*block_args) }
  else
    clone.tap { |r| r.select_values += args if args_valid? args }
  end
end

#sql(raw_sql) ⇒ Object



51
52
53
# File 'lib/perry/relation/query_methods.rb', line 51

def sql(raw_sql)
  clone.tap { |r| r.raw_sql_value = raw_sql }
end

#where(*args) ⇒ Object



31
32
33
# File 'lib/perry/relation/query_methods.rb', line 31

def where(*args)
  clone.tap { |r| r.where_values += args.compact.select { |i| args_valid? i } if args_valid? args }
end