Module: Parascope::Query::ApiMethods

Included in:
Parascope::Query
Defined in:
lib/parascope/query/api_methods.rb

Instance Method Summary collapse

Instance Method Details

#base_scope(&block) ⇒ Object



3
4
5
6
7
# File 'lib/parascope/query/api_methods.rb', line 3

def base_scope(&block)
  return @base_scope unless block_given?

  @base_scope = block
end

#defaults(params = nil) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/parascope/query/api_methods.rb', line 9

def defaults(params = nil)
  @defaults ||= {}

  return @defaults if params.nil?

  @defaults = @defaults.merge(params)
end

#guard(&block) ⇒ Object



36
37
38
# File 'lib/parascope/query/api_methods.rb', line 36

def guard(&block)
  guard_blocks.push block
end

#guard_blocksObject



48
49
50
# File 'lib/parascope/query/api_methods.rb', line 48

def guard_blocks
  @guard_blocks ||= []
end

#query_blocksObject



44
45
46
# File 'lib/parascope/query/api_methods.rb', line 44

def query_blocks
  @query_blocks ||= []
end

#query_by(*presence_fields, **value_fields, &block) ⇒ Object Also known as: query



25
26
27
28
29
30
31
# File 'lib/parascope/query/api_methods.rb', line 25

def query_by(*presence_fields, **value_fields, &block)
  query_blocks.push Query::ApiBlock.new(
    presence_fields: presence_fields,
    value_fields:    value_fields,
    block:           block
  )
end

#sift_blocksObject



40
41
42
# File 'lib/parascope/query/api_methods.rb', line 40

def sift_blocks
  @sift_blocks ||= []
end

#sift_by(*presence_fields, **value_fields, &block) ⇒ Object Also known as: sifter



17
18
19
20
21
22
23
# File 'lib/parascope/query/api_methods.rb', line 17

def sift_by(*presence_fields, **value_fields, &block)
  sift_blocks.push Query::ApiBlock.new(
    presence_fields: presence_fields,
    value_fields:    value_fields,
    block:           block
  )
end