class TransactionQL::NumericExpression

Public Class Methods

new(column, other, operator) click to toggle source
# File lib/transaction_ql/expressions.rb, line 9
def initialize(column, other, operator)
  @column = column
  @other = other
  @operator = operator
end

Public Instance Methods

matches?(hash) click to toggle source
# File lib/transaction_ql/expressions.rb, line 15
def matches?(hash)
  case @other
  when Numeric
    hash.fetch(@column).send @operator, @other
  when String
    if !hash[@other].is_a? Numeric
      raise "Column `#{@other}` is not numeric!"
    end
    hash.fetch(@column).send @operator, hash.fetch(@other)
  else
    raise 'Unsupported right hand type.'
  end
end