Class: SearchCopGrammar::Attributes::String

Inherits:
Base
  • Object
show all
Defined in:
lib/search_cop_grammar/attributes.rb

Direct Known Subclasses

Text

Instance Attribute Summary

Attributes inherited from Base

#attribute, #column_name, #options, #table_alias

Instance Method Summary collapse

Methods inherited from Base

#compatible?, #fulltext?, #initialize, #map, #method_missing, #respond_to?

Constructor Details

This class inherits a constructor from SearchCopGrammar::Attributes::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SearchCopGrammar::Attributes::Base

Instance Method Details

#matches(value) ⇒ Object



144
145
146
# File 'lib/search_cop_grammar/attributes.rb', line 144

def matches(value)
  super matches_value(value)
end

#matches_value(value) ⇒ Object



138
139
140
141
142
# File 'lib/search_cop_grammar/attributes.rb', line 138

def matches_value(value)
  return value.gsub(/\*/, "%") if (options[:left_wildcard] != false && value.strip =~ /^[^*]+\*$|^\*[^*]+$/) || value.strip =~ /^[^*]+\*$/

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