Class: Conjur::DSL2::YAML::Handler::Base
- Defined in:
- lib/conjur/dsl2/yaml/handler.rb
Overview
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.
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#alias(anchor) ⇒ Object
An alias is encountered in the document.
-
#end_mapping ⇒ Object
End the current mapping.
-
#end_sequence ⇒ Object
End the current sequence.
-
#handler ⇒ Object
Handlers are organized in a stack.
-
#initialize(parent) ⇒ Base
constructor
A new instance of Base.
-
#pop_handler ⇒ Object
Pop this handler off the stack, indicating that it’s complete.
-
#push_handler ⇒ Object
Push this handler onto the stack.
-
#result ⇒ Object
Each handler should implement this method to return the result object (which may only be partially constructed).
-
#scalar(value, tag, quoted) ⇒ Object
Process a scalar value.
-
#start_mapping(tag) ⇒ Object
Start a new mapping with the specified tag.
-
#start_sequence ⇒ Object
Start a new sequence.
Constructor Details
#initialize(parent) ⇒ Base
Returns a new instance of Base.
17 18 19 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 17 def initialize parent @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
15 16 17 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 15 def parent @parent end |
Instance Method Details
#alias(anchor) ⇒ Object
An alias is encountered in the document. The value may be looked up in the root Handler anchor
hash.
42 43 44 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 42 def alias anchor raise "Unexpected alias #{anchor}" end |
#end_mapping ⇒ Object
End the current mapping. The handler should populate the mapping into the parent handler.
64 65 66 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 64 def end_mapping raise "Unexpected end of mapping" end |
#end_sequence ⇒ Object
End the current sequence. The handler should populate the sequence into the parent handler.
59 60 61 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 59 def end_sequence raise "Unexpected end of sequence" end |
#handler ⇒ Object
Handlers are organized in a stack. Each handler can find the root Handler by traversing up the stack.
27 28 29 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 27 def handler parent.handler end |
#pop_handler ⇒ Object
Pop this handler off the stack, indicating that it’s complete.
37 38 39 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 37 def pop_handler handler.pop_handler end |
#push_handler ⇒ Object
Push this handler onto the stack.
32 33 34 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 32 def push_handler handler.push_handler self end |
#result ⇒ Object
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).
24 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 24 def result; raise "Not implemented"; end |
#scalar(value, tag, quoted) ⇒ Object
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.
71 72 73 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 71 def scalar value, tag, quoted raise "Unexpected scalar" end |
#start_mapping(tag) ⇒ Object
Start a new mapping with the specified tag. If the handler wants to accept the message, it should return a new handler.
48 49 50 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 48 def start_mapping tag raise "Unexpected mapping" end |
#start_sequence ⇒ Object
Start a new sequence. If the handler wants to accept the message, it should return a new handler.
54 55 56 |
# File 'lib/conjur/dsl2/yaml/handler.rb', line 54 def start_sequence raise "Unexpected sequence" end |