Class: SetBuilder::Modifiers::StringModifier
Instance Attribute Summary
#operator, #values
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, to_hash, to_json, #to_s, #valid?, #valid_argument_of_type?, #valid_arguments?, #valid_date_argument?, #valid_number_argument?, #valid_operator?
Class Method Details
.negate(operator) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/set_builder/modifiers/string_modifier.rb', line 25
def self.negate(operator)
case operator
when :contains
"does not contain"
when :begins_with
"does not begin with"
when :ends_with
"does not end with"
when :is
"is not"
end
end
|
.operators ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/set_builder/modifiers/string_modifier.rb', line 10
def self.operators
{
:contains => [:string],
:does_not_contain => [:string],
:begins_with => [:string],
:does_not_begin_with => [:string],
:ends_with => [:string],
:does_not_end_with => [:string],
:is => [:string],
:is_not => [:string]
}
end
|
Instance Method Details
#build_conditions_for(selector, operator = nil) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/set_builder/modifiers/string_modifier.rb', line 40
def build_conditions_for(selector, operator=nil)
operator ||= self.operator
case operator
when :does_not_contain
negate(selector, :contains)
when :does_not_begin_with
negate(selector, :begins_with)
when :does_not_end_with
negate(selector, :ends_with)
when :is_not
negate(selector, :is)
when :is
["#{selector}=?", values[0]]
else
["#{selector} LIKE ?", get_like_value_for_operator]
end
end
|