Class: SafetyPin::Query::WhereCondition

Inherits:
Object
  • Object
show all
Defined in:
lib/safety_pin/query/where_condition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value, comparator = "=") ⇒ WhereCondition

Returns a new instance of WhereCondition.



6
7
8
9
10
# File 'lib/safety_pin/query/where_condition.rb', line 6

def initialize(name, value, comparator = "=")
  @name = name
  @value = value
  @comparator = comparator
end

Instance Attribute Details

#comparatorObject (readonly)

Returns the value of attribute comparator.



4
5
6
# File 'lib/safety_pin/query/where_condition.rb', line 4

def comparator
  @comparator
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/safety_pin/query/where_condition.rb', line 4

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/safety_pin/query/where_condition.rb', line 4

def value
  @value
end

Instance Method Details

#==(object) ⇒ Object



16
17
18
# File 'lib/safety_pin/query/where_condition.rb', line 16

def ==(object)
  self.name == object.name and self.value == object.value and self.comparator == object.comparator
end

#eql?(object) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/safety_pin/query/where_condition.rb', line 20

def eql?(object)
  self == object
end

#sql_fragmentObject



12
13
14
# File 'lib/safety_pin/query/where_condition.rb', line 12

def sql_fragment
  "[#{name}] #{comparator} '#{value}'"
end