module Upmin::DataMapper::Query

Public Instance Methods

results() click to toggle source
# File lib/upmin/data_mapper/query.rb, line 4
def results
  return klass.model_class.all(prepared_search)
end

Private Instance Methods

create_operator(key) click to toggle source
# File lib/upmin/data_mapper/query.rb, line 27
def create_operator(key)
  if m = key.to_s.match(/(.*)_(#{valid_suffixes.join("|")})/)
    target = m.captures.first
    operator = operator_for(m.captures.second)
    return DataMapper::Query::Operator.new(target, operator)
  else
    return nil
  end
end
operator_for(suffix) click to toggle source
# File lib/upmin/data_mapper/query.rb, line 45
def operator_for(suffix)
  op_map = {
    gteq: :gte,
    lteq: :lte,
    cont: :like
  }
  return op_map[suffix.to_sym]
end
valid_suffixes() click to toggle source
# File lib/upmin/data_mapper/query.rb, line 37
def valid_suffixes
  return [
    :gteq,
    :lteq,
    :cont
  ]
end