Module: RPCMapper::QueryMethods

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fresh_valueObject

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



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

def fresh_value
  @fresh_value
end

#from_valueObject

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



3
4
5
# File 'lib/rpc_mapper/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/rpc_mapper/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/rpc_mapper/relation/query_methods.rb', line 3

def having_values
  @having_values
end

#includes_valuesObject

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



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

def includes_values
  @includes_values
end

#joins_valuesObject

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



3
4
5
# File 'lib/rpc_mapper/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/rpc_mapper/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/rpc_mapper/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/rpc_mapper/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/rpc_mapper/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/rpc_mapper/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/rpc_mapper/relation/query_methods.rb', line 3

def where_values
  @where_values
end

Instance Method Details

#fresh(val = true) ⇒ Object



52
53
54
55
56
57
# File 'lib/rpc_mapper/relation/query_methods.rb', line 52

def fresh(val=true)
  clone.tap do |r|
    r.fresh_value = val
    r.reset_queries if r.fresh_value
  end
end

#from(table) ⇒ Object



48
49
50
# File 'lib/rpc_mapper/relation/query_methods.rb', line 48

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

#group(*args) ⇒ Object



15
16
17
# File 'lib/rpc_mapper/relation/query_methods.rb', line 15

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

#having(*args) ⇒ Object



36
37
38
# File 'lib/rpc_mapper/relation/query_methods.rb', line 36

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

#includes(*args) ⇒ Object



27
28
29
30
# File 'lib/rpc_mapper/relation/query_methods.rb', line 27

def includes(*args)
  args.reject! { |a| a.nil? }
  clone.tap { |r| r.includes_values += (r.includes_values + args).flatten.uniq if args_valid? args }
end

#joins(*args) ⇒ Object



23
24
25
# File 'lib/rpc_mapper/relation/query_methods.rb', line 23

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

#limit(value = true) ⇒ Object



40
41
42
# File 'lib/rpc_mapper/relation/query_methods.rb', line 40

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

#offset(value = true) ⇒ Object



44
45
46
# File 'lib/rpc_mapper/relation/query_methods.rb', line 44

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

#order(*args) ⇒ Object



19
20
21
# File 'lib/rpc_mapper/relation/query_methods.rb', line 19

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

#select(*args) ⇒ Object



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

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



59
60
61
# File 'lib/rpc_mapper/relation/query_methods.rb', line 59

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

#where(*args) ⇒ Object



32
33
34
# File 'lib/rpc_mapper/relation/query_methods.rb', line 32

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