Class: Arel::Nodes::Or
- Inherits:
-
Object
- Object
- Arel::Nodes::Or
- Includes:
- ArelExtensions::BooleanFunctions
- Defined in:
- lib/arel_extensions/boolean_functions.rb
Overview
For some reason, Arel’s And is properly defined as variadic (it stores @children, and hashes it all). However Arel’s Or is defined as binary, with only @left and @right, and hashing only @left and @right.
So reimplement its ctor and accessors.
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(*children) ⇒ Or
constructor
A new instance of Or.
- #initialize_copy(other) ⇒ Object
- #left ⇒ Object
- #right ⇒ Object
Methods included from ArelExtensions::BooleanFunctions
Constructor Details
#initialize(*children) ⇒ Or
Returns a new instance of Or.
58 59 60 |
# File 'lib/arel_extensions/boolean_functions.rb', line 58 def initialize *children @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
48 49 50 |
# File 'lib/arel_extensions/boolean_functions.rb', line 48 def children @children end |
Class Method Details
.new(*children) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/arel_extensions/boolean_functions.rb', line 50 def self.new *children children = children.flatten.map { |c| c.is_a?(self) ? c.children : c }.flatten super(*children) end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
79 80 81 82 |
# File 'lib/arel_extensions/boolean_functions.rb', line 79 def eql?(other) self.class == other.class && children == other.children end |
#hash ⇒ Object
75 76 77 |
# File 'lib/arel_extensions/boolean_functions.rb', line 75 def hash children.hash end |
#initialize_copy(other) ⇒ Object
62 63 64 65 |
# File 'lib/arel_extensions/boolean_functions.rb', line 62 def initialize_copy(other) super @children = other.children.copy if other.children end |
#left ⇒ Object
67 68 69 |
# File 'lib/arel_extensions/boolean_functions.rb', line 67 def left children.first end |
#right ⇒ Object
71 72 73 |
# File 'lib/arel_extensions/boolean_functions.rb', line 71 def right children[1] end |