Class: Quercle::Predicate

Inherits:
Object
  • Object
show all
Defined in:
lib/quercle/predicate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Predicate

Returns a new instance of Predicate.



4
5
6
7
# File 'lib/quercle/predicate.rb', line 4

def initialize(json)
  @field = json['field']
  @operation = Operator.get(json['operator'], json['value'])
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



3
4
5
# File 'lib/quercle/predicate.rb', line 3

def field
  @field
end

#operationObject (readonly)

Returns the value of attribute operation.



3
4
5
# File 'lib/quercle/predicate.rb', line 3

def operation
  @operation
end

Instance Method Details

#to_aObject



9
10
11
# File 'lib/quercle/predicate.rb', line 9

def to_a
  ["#{field} #{operation.sql_fragment}", operation.value]
end