module Taketo::AssociatedNodes::InstanceMethods
Public Class Methods
new(*args)
click to toggle source
# File lib/taketo/associated_nodes.rb, line 54 def initialize(*args) @nodes = {} end
Public Instance Methods
find(singular_node_name, name) { || ... }
click to toggle source
# File lib/taketo/associated_nodes.rb, line 58 def find(singular_node_name, name) send("find_#{singular_node_name}", name) or if block_given? yield else raise KeyError, "#{singular_node_name} #{name} not found for #{qualified_name}" end end
has_deeply_nested_nodes?(name_plural)
click to toggle source
# File lib/taketo/associated_nodes.rb, line 81 def has_deeply_nested_nodes?(name_plural) has_nodes?(name_plural) || self.class.node_types.any? { |n| nodes(n).any? { |node| node.has_deeply_nested_nodes?(name_plural) } } end
has_nodes?(name_plural)
click to toggle source
# File lib/taketo/associated_nodes.rb, line 74 def has_nodes?(name_plural) unless self.class.node_types.include?(name_plural) raise NodesNotDefinedError, "#{name_plural} not defined for #{qualified_name}" end @nodes.fetch(name_plural) { [] }.any? end
nodes(name_plural)
click to toggle source
# File lib/taketo/associated_nodes.rb, line 67 def nodes(name_plural) unless self.class.node_types.include?(name_plural) raise NodesNotDefinedError, "#{name_plural} not defined for #{qualified_name}" end @nodes[name_plural] ||= Taketo::Support::NamedNodesCollection.new end
qualified_name()
click to toggle source
Ovverride for better error messages
# File lib/taketo/associated_nodes.rb, line 87 def qualified_name self.class.name end