Class: Squeel::Nodes::Predicate
- Inherits:
-
Object
- Object
- Squeel::Nodes::Predicate
- Includes:
- PredicateOperators, PredicateMethods
- Defined in:
- lib/squeel/nodes/predicate.rb
Instance Attribute Summary collapse
-
#expr ⇒ Object
readonly
Returns the value of attribute expr.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #%(val) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(expr, method_name = :eq, value = :__undefined__) ⇒ Predicate
constructor
A new instance of Predicate.
-
#to_sym ⇒ Object
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.
- #value? ⇒ Boolean
Methods included from PredicateOperators
Methods included from PredicateMethods
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
#expr ⇒ Object (readonly)
Returns the value of attribute expr.
12 13 14 |
# File 'lib/squeel/nodes/predicate.rb', line 12 def expr @expr end |
#method_name ⇒ Object (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 |
#value ⇒ Object
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: ==
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 |
#hash ⇒ Object
27 28 29 |
# File 'lib/squeel/nodes/predicate.rb', line 27 def hash [self.class, expr, method_name, value].hash end |
#to_sym ⇒ Object
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
31 32 33 |
# File 'lib/squeel/nodes/predicate.rb', line 31 def value? @value != :__undefined__ end |