module QueryMethodsExtend::Operators

Public Class Methods

gt(agrs) click to toggle source
# File lib/query_methods_extend/operators.rb, line 4
def self.gt agrs
  @extend_operator_string = '>'
  operator_basic agrs
end
gteq(agrs) click to toggle source
# File lib/query_methods_extend/operators.rb, line 9
def self.gteq agrs
  @extend_operator_string = '>='
  operator_basic agrs
end
lt(agrs) click to toggle source
# File lib/query_methods_extend/operators.rb, line 14
def self.lt agrs
  @extend_operator_string = '<'
  operator_basic agrs
end
lteq(agrs) click to toggle source
# File lib/query_methods_extend/operators.rb, line 19
def self.lteq agrs
  @extend_operator_string = '<='
  operator_basic agrs
end
operator_basic(agrs) click to toggle source
# File lib/query_methods_extend/operators.rb, line 25
def self.operator_basic agrs
  if agrs.class == Hash
    items = self
    agrs.each do |agr|
      field, value = agr
      items = items.where("#{self.table_name}.#{field} #{@extend_operator_string} ?", value)
    end
    return items
  else
    raise "Operators '#{@extend_operator_string}' with agruments should be a HASH"
  end
end