class Conjur::DSL2::YAML::Handler::Base
An abstract Base
handler. The handler will receive each document message within its particular context (sequence, mapping, etc).
The handler can decide that the message is not allowed by not implementing the message.
Attributes
Public Class Methods
# File lib/conjur/dsl2/yaml/handler.rb, line 17 def initialize parent @parent = parent end
Public Instance Methods
An alias is encountered in the document. The value may be looked up in the root Handler
anchor
hash.
# File lib/conjur/dsl2/yaml/handler.rb, line 42 def alias anchor raise "Unexpected alias #{anchor}" end
End the current mapping. The handler should populate the mapping into the parent handler.
# File lib/conjur/dsl2/yaml/handler.rb, line 64 def end_mapping raise "Unexpected end of mapping" end
End the current sequence. The handler should populate the sequence into the parent handler.
# File lib/conjur/dsl2/yaml/handler.rb, line 59 def end_sequence raise "Unexpected end of sequence" end
Handlers are organized in a stack. Each handler can find the root Handler
by traversing up the stack.
# File lib/conjur/dsl2/yaml/handler.rb, line 27 def handler parent.handler end
Pop this handler off the stack, indicating that it’s complete.
# File lib/conjur/dsl2/yaml/handler.rb, line 37 def pop_handler handler.pop_handler end
Push this handler onto the stack.
# File lib/conjur/dsl2/yaml/handler.rb, line 32 def push_handler handler.push_handler self end
Each handler should implement this method to return the result object (which may only be partially constructed). This method is used by the root handler to associate the handler result with an anchor (if applicable).
# File lib/conjur/dsl2/yaml/handler.rb, line 24 def result; raise "Not implemented"; end
Process a scalar value. It may be a map key, a map value, or a sequence value. The handler should return a result from this method, so that the root Handler
can associate it with an anchor, if any.
# File lib/conjur/dsl2/yaml/handler.rb, line 71 def scalar value, tag, quoted raise "Unexpected scalar" end
Start a new mapping with the specified tag. If the handler wants to accept the message, it should return a new handler.
# File lib/conjur/dsl2/yaml/handler.rb, line 48 def start_mapping tag raise "Unexpected mapping" end
Start a new sequence. If the handler wants to accept the message, it should return a new handler.
# File lib/conjur/dsl2/yaml/handler.rb, line 54 def start_sequence raise "Unexpected sequence" end
Protected Instance Methods
# File lib/conjur/dsl2/yaml/handler.rb, line 77 def scalar_value value, tag, quoted, record_type if type = type_of(tag, record_type) type.new.tap do |record| record.id = value end else SafeYAML::Transform.to_guessed_type(value, quoted, SafeYAML::OPTIONS) end end
# File lib/conjur/dsl2/yaml/handler.rb, line 87 def type_of tag, record_type if tag && tag.match(/!(.*)/) type_name = $1.underscore.camelize begin Conjur::DSL2::Types.const_get(type_name) rescue NameError raise "Unrecognized data type '#{tag}'" end else record_type end end