class ParamsReady::Query::Like

Public Class Methods

test(record, attribute_name, value) click to toggle source
# File lib/params_ready/query/predicate_operator.rb, line 72
def self.test(record, attribute_name, value)
  attribute = record.send attribute_name
  result = Regexp.new(value, Regexp::IGNORECASE) =~ attribute
  result.nil? ? false : true
end
to_query(attribute_name, value) click to toggle source
# File lib/params_ready/query/predicate_operator.rb, line 68
def self.to_query(attribute_name, value)
  attribute_name.matches("%#{value}%")
end