class AgnosticBackend::Queryable::TreeNode

Attributes

children[R]

include Enumerable

context[R]

Public Class Methods

new(children = [], context = nil) click to toggle source
# File lib/agnostic_backend/queryable/tree_node.rb, line 10
def initialize(children = [], context = nil)
  @children, @context = children, context
end

Public Instance Methods

==(other) click to toggle source

def each(&block)

block.call(self)
children.each{|child| child.each(&block)  }

end

# 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) click to toggle source
# File lib/agnostic_backend/queryable/tree_node.rb, line 33
def accept(visitor)
  visitor.visit(self)
end

Private Instance Methods

attribute_component(attribute:, context: nil) click to toggle source
# File lib/agnostic_backend/queryable/tree_node.rb, line 39
def attribute_component(attribute:, context: nil)
  Attribute.new(attribute, parent: self, context: context)
end
value_component(value:, context: nil, type:) click to toggle source
# File lib/agnostic_backend/queryable/tree_node.rb, line 43
def value_component(value:, context: nil, type:)
  Value.new(convert_to(type, value), parent: self, context: context)
end