Class: Squeel::Nodes::Predicate

Inherits:
Object
  • Object
show all
Includes:
PredicateOperators, PredicateMethods
Defined in:
lib/squeel/nodes/predicate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PredicateOperators

#&, #-@, #|

Methods included from PredicateMethods

included

Constructor Details

#initialize(expr, method_name = :eq, value = :__undefined__) ⇒ Predicate

Returns a new instance of Predicate.



14
15
16
# File 'lib/squeel/nodes/predicate.rb', line 14

def initialize(expr, method_name = :eq, value = :__undefined__)
  @expr, @method_name, @value = expr, method_name, value
end

Instance Attribute Details

#exprObject (readonly)

Returns the value of attribute expr.



12
13
14
# File 'lib/squeel/nodes/predicate.rb', line 12

def expr
  @expr
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



12
13
14
# File 'lib/squeel/nodes/predicate.rb', line 12

def method_name
  @method_name
end

#valueObject

Returns the value of attribute value.



11
12
13
# File 'lib/squeel/nodes/predicate.rb', line 11

def value
  @value
end

Instance Method Details

#%(val) ⇒ Object



35
36
37
38
# File 'lib/squeel/nodes/predicate.rb', line 35

def %(val)
  @value = val
  self
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/squeel/nodes/predicate.rb', line 18

def eql?(other)
  self.class.eql?(other.class) &&
  self.expr.eql?(other.expr) &&
  self.method_name.eql?(other.method_name) &&
  self.value.eql?(other.value)
end

#hashObject



27
28
29
# File 'lib/squeel/nodes/predicate.rb', line 27

def hash
  [self.class, expr, method_name, value].hash
end

#to_symObject

expand_hash_conditions_for_aggregates assumes our hash keys can be converted to symbols, so this has to be implemented, but it doesn’t really have to do anything useful.



43
44
45
# File 'lib/squeel/nodes/predicate.rb', line 43

def to_sym
  nil
end

#value?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/squeel/nodes/predicate.rb', line 31

def value?
  @value != :__undefined__
end