class Conjur::Policy::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/policy/yaml/handler.rb, line 17 def initialize parent, anchor @parent = parent @anchor = anchor 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/policy/yaml/handler.rb, line 38 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/policy/yaml/handler.rb, line 60 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/policy/yaml/handler.rb, line 55 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/policy/yaml/handler.rb, line 23 def handler parent.handler end
Pop this handler off the stack, indicating that it's complete.
# File lib/conjur/policy/yaml/handler.rb, line 33 def pop_handler handler.pop_handler end
Push this handler onto the stack.
# File lib/conjur/policy/yaml/handler.rb, line 28 def push_handler handler.push_handler self end
Process a scalar value. It may be a map key, a map value, or a sequence value.
# File lib/conjur/policy/yaml/handler.rb, line 65 def scalar value, tag, quoted, anchor 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/policy/yaml/handler.rb, line 44 def start_mapping tag, anchor 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/policy/yaml/handler.rb, line 50 def start_sequence anchor raise "Unexpected sequence" end
Protected Instance Methods
# File lib/conjur/policy/yaml/handler.rb, line 71 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/policy/yaml/handler.rb, line 81 def type_of tag, record_type if tag && tag.match(/!(.*)/) type_name = $1.underscore.camelize begin Conjur::Policy::Types.const_get(type_name) rescue NameError raise "Unrecognized data type '#{tag}'" end else record_type end end