Class: AgnosticBackend::Queryable::CriteriaBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/agnostic_backend/queryable/criteria_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_builder) ⇒ CriteriaBuilder

Returns a new instance of CriteriaBuilder.



7
8
9
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 7

def initialize(query_builder)
  @context = query_builder
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 5

def context
  @context
end

Instance Method Details

#and(*criteria) ⇒ Object Also known as: all



79
80
81
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 79

def and(*criteria)
  Operations::And.new(operands: criteria, context: context)
end

#asc(attribute) ⇒ Object



67
68
69
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 67

def asc(attribute)
  Operations::Ascending.new(attribute: attribute, context: context)
end

#contains(attribute, value) ⇒ Object



51
52
53
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 51

def contains(attribute, value)
  Criteria::Contains.new(attribute: attribute, value: value, context: context)
end

#desc(attribute) ⇒ Object



71
72
73
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 71

def desc(attribute)
  Operations::Descending.new(attribute: attribute, context: context)
end

#eq(attribute, value) ⇒ Object



11
12
13
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 11

def eq(attribute, value)
  Criteria::Equal.new(attribute: attribute, value: value, context: context)
end

#free_text(attribute, value) ⇒ Object



59
60
61
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 59

def free_text(attribute, value)
  Criteria::FreeText.new(attribute: attribute, value: value, context: context)
end

#fuzzy(attribute, value, fuzziness) ⇒ Object



63
64
65
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 63

def fuzzy(attribute, value, fuzziness)
  Criteria::Fuzzy.new(attribute: attribute, value: value, context: context, fuzziness: fuzziness)
end

#ge(attribute, value) ⇒ Object



27
28
29
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 27

def ge(attribute, value)
  Criteria::GreaterEqual.new(attribute: attribute, value: value, context: context)
end

#ge_and_le(attribute, left_limit, right_limit) ⇒ Object



47
48
49
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 47

def ge_and_le(attribute, left_limit, right_limit)
  Criteria::GreaterEqualAndLessEqual.new(attribute: attribute, left_value: left_limit, right_value: right_limit, context: context)
end

#ge_and_lt(attribute, left_limit, right_limit) ⇒ Object



43
44
45
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 43

def ge_and_lt(attribute, left_limit, right_limit)
  Criteria::GreaterEqualAndLess.new(attribute: attribute, left_value: left_limit, right_value: right_limit, context: context)
end

#gt(attribute, value) ⇒ Object



19
20
21
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 19

def gt(attribute, value)
  Criteria::Greater.new(attribute: attribute, value: value, context: context)
end

#gt_and_le(attribute, left_limit, right_limit) ⇒ Object



39
40
41
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 39

def gt_and_le(attribute, left_limit, right_limit)
  Criteria::GreaterAndLessEqual.new(attribute: attribute, left_value: left_limit, right_value: right_limit, context: context)
end

#gt_and_lt(attribute, left_limit, right_limit) ⇒ Object



35
36
37
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 35

def gt_and_lt(attribute, left_limit, right_limit)
  Criteria::GreaterAndLess.new(attribute: attribute, left_value: left_limit, right_value: right_limit, context: context)
end

#le(attribute, value) ⇒ Object



31
32
33
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 31

def le(attribute, value)
  Criteria::LessEqual.new(attribute: attribute, value: value, context: context)
end

#lt(attribute, value) ⇒ Object



23
24
25
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 23

def lt(attribute, value)
  Criteria::Less.new(attribute: attribute, value: value, context: context)
end

#neq(attribute, value) ⇒ Object



15
16
17
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 15

def neq(attribute, value)
  Criteria::NotEqual.new(attribute: attribute, value: value, context: context)
end

#not(criterion) ⇒ Object



75
76
77
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 75

def not(criterion)
  Operations::Not.new(operand: criterion, context: context)
end

#or(*criteria) ⇒ Object Also known as: any



83
84
85
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 83

def or(*criteria)
  Operations::Or.new(operands: criteria, context: context)
end

#starts(attribute, value) ⇒ Object



55
56
57
# File 'lib/agnostic_backend/queryable/criteria_builder.rb', line 55

def starts(attribute, value)
  Criteria::Starts.new(attribute: attribute, value: value, context: context)
end