class NoSE::Condition
A single condition in a where clause
Attributes
field[R]
is_range[R]
operator[R]
range?[R]
value[R]
Public Class Methods
new(field, operator, value)
click to toggle source
# File lib/nose/statements.rb, line 9 def initialize(field, operator, value) @field = field @operator = operator @is_range = [:>, :>=, :<, :<=].include? operator @value = value # XXX: Not frozen by now to support modification during query execution # freeze end
Public Instance Methods
==(other)
click to toggle source
Compare conditions equal by their field and operator @return [Boolean]
# File lib/nose/statements.rb, line 25 def ==(other) @field == other.field && @operator == other.operator end
Also aliased as: eql?
hash()
click to toggle source
# File lib/nose/statements.rb, line 30 def hash Zlib.crc32 [@field.id, @operator].to_s end
inspect()
click to toggle source
# File lib/nose/statements.rb, line 19 def inspect "#{@field.inspect} #{@operator} #{value}" end
resolve_foreign_key()
click to toggle source
If the condition is on a foreign key, resolve it to the primary key of the related entity @return [Condition]
# File lib/nose/statements.rb, line 37 def resolve_foreign_key return self unless field.is_a?(Fields::ForeignKeyField) Condition.new @field.entity.id_field, @operator, @value end