class AttrSearchableGrammar::Attributes::String

Public Instance Methods

matches(value) click to toggle source
Calls superclass method
# File lib/attr_searchable_grammar/attributes.rb, line 128
def matches(value)
  super matches_value(value)
end
matches_value(value) click to toggle source
# File lib/attr_searchable_grammar/attributes.rb, line 122
def matches_value(value)
  return value.gsub(/\*/, "%") if (options[:left_wildcard] != false && value.strip =~ /^[^*]+\*$|^\*[^*]+$/) || value.strip =~ /^[^*]+\*$/

  options[:left_wildcard] != false ? "%#{value}%" : "#{value}%"
end