Class: AgnosticBackend::Queryable::TreeNode
- Inherits:
-
Object
- Object
- AgnosticBackend::Queryable::TreeNode
- Includes:
- Utilities
- Defined in:
- lib/agnostic_backend/queryable/tree_node.rb
Direct Known Subclasses
Attribute, Criteria::Criterion, Expressions::Expression, Operations::Operation, Query, Value
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
include Enumerable.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#==(other) ⇒ Object
def each(&block) block.call(self) children.each{|child| child.each(&block) } end.
- #accept(visitor) ⇒ Object
-
#initialize(children = [], context = nil) ⇒ TreeNode
constructor
A new instance of TreeNode.
Methods included from Utilities
Constructor Details
#initialize(children = [], context = nil) ⇒ TreeNode
Returns a new instance of TreeNode.
10 11 12 |
# File 'lib/agnostic_backend/queryable/tree_node.rb', line 10 def initialize(children = [], context = nil) @children, @context = children, context end |
Instance Attribute Details
#children ⇒ Object (readonly)
include Enumerable
7 8 9 |
# File 'lib/agnostic_backend/queryable/tree_node.rb', line 7 def children @children end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/agnostic_backend/queryable/tree_node.rb', line 8 def context @context end |
Instance Method Details
#==(other) ⇒ Object
def each(&block)
block.call(self)
children.each{|child| child.each(&block) }
end
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/agnostic_backend/queryable/tree_node.rb', line 19 def ==(other) return true if self.__id__ == other.__id__ return false if other.nil? return false unless other.is_a? AgnosticBackend::Queryable::TreeNode return false unless other.children.size == children.size children_pairs = other.children.zip(children) other.class == self.class && children_pairs.all? do |first_child, second_child| first_child == second_child end end |
#accept(visitor) ⇒ Object
33 34 35 |
# File 'lib/agnostic_backend/queryable/tree_node.rb', line 33 def accept(visitor) visitor.visit(self) end |