class Openapi3Parser::Node::Placeholder
Attributes
field[R]
node_factory[R]
parent_context[R]
Public Class Methods
each(node_data, &block)
click to toggle source
Used to iterate through hashes or arrays that may contain Placeholder
objects where these are resolved to being nodes before iteration
# File lib/openapi3_parser/node/placeholder.rb, line 21 def self.each(node_data, &block) resolved = if node_data.respond_to?(:keys) node_data.transform_values do |value| resolve(value) end else node_data.map { |item| resolve(item) } end resolved.each(&block) end
new(node_factory, field, parent_context)
click to toggle source
# File lib/openapi3_parser/node/placeholder.rb, line 38 def initialize(node_factory, field, parent_context) @node_factory = node_factory @field = field @parent_context = parent_context end
resolve(potential_placeholder)
click to toggle source
# File lib/openapi3_parser/node/placeholder.rb, line 10 def self.resolve(potential_placeholder) if potential_placeholder.is_a?(Placeholder) potential_placeholder.node else potential_placeholder end end
Public Instance Methods
node()
click to toggle source
# File lib/openapi3_parser/node/placeholder.rb, line 44 def node @node ||= begin node_context = Context.next_field(parent_context, field, node_factory.context) node_factory.node(node_context) end end