class SetBuilder::Modifiers::StringModifier
Public Class Methods
negate(operator)
click to toggle source
# 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()
click to toggle source
# 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
Public Instance Methods
build_conditions_for(selector, operator=nil)
click to toggle source
# 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
Private Instance Methods
get_like_value_for_operator()
click to toggle source
# File lib/set_builder/modifiers/string_modifier.rb, line 66 def get_like_value_for_operator case operator when :contains "%#{values[0]}%" when :begins_with "#{values[0]}%" when :ends_with "%#{values[0]}" end end