Class: Conjur::Policy::YAML::Handler::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/conjur/policy/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.

Direct Known Subclasses

MapEntry, Mapping, Root, Sequence

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, anchor) ⇒ Base

Returns a new instance of Base.



17
18
19
20
# File 'lib/conjur/policy/yaml/handler.rb', line 17

def initialize parent, anchor
  @parent = parent
  @anchor = anchor
end

Instance Attribute Details

#anchorObject (readonly)

Returns the value of attribute anchor.



15
16
17
# File 'lib/conjur/policy/yaml/handler.rb', line 15

def anchor
  @anchor
end

#parentObject (readonly)

Returns the value of attribute parent.



15
16
17
# File 'lib/conjur/policy/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.



38
39
40
# File 'lib/conjur/policy/yaml/handler.rb', line 38

def alias anchor
  raise "Unexpected alias #{anchor}"
end

#end_mappingObject

End the current mapping. The handler should populate the mapping into the parent handler.



60
61
62
# File 'lib/conjur/policy/yaml/handler.rb', line 60

def end_mapping
  raise "Unexpected end of mapping"
end

#end_sequenceObject

End the current sequence. The handler should populate the sequence into the parent handler.



55
56
57
# File 'lib/conjur/policy/yaml/handler.rb', line 55

def end_sequence
  raise "Unexpected end of sequence"
end

#handlerObject

Handlers are organized in a stack. Each handler can find the root Handler by traversing up the stack.



23
24
25
# File 'lib/conjur/policy/yaml/handler.rb', line 23

def handler
  parent.handler
end

#pop_handlerObject

Pop this handler off the stack, indicating that it’s complete.



33
34
35
# File 'lib/conjur/policy/yaml/handler.rb', line 33

def pop_handler
  handler.pop_handler
end

#push_handlerObject

Push this handler onto the stack.



28
29
30
# File 'lib/conjur/policy/yaml/handler.rb', line 28

def push_handler
  handler.push_handler self
end

#scalar(value, tag, quoted, anchor) ⇒ Object

Process a scalar value. It may be a map key, a map value, or a sequence value.



65
66
67
# File 'lib/conjur/policy/yaml/handler.rb', line 65

def scalar value, tag, quoted, anchor
  raise "Unexpected scalar"
end

#start_mapping(tag, anchor) ⇒ Object

Start a new mapping with the specified tag. If the handler wants to accept the message, it should return a new handler.



44
45
46
# File 'lib/conjur/policy/yaml/handler.rb', line 44

def start_mapping tag, anchor
  raise "Unexpected mapping"
end

#start_sequence(anchor) ⇒ Object

Start a new sequence. If the handler wants to accept the message, it should return a new handler.



50
51
52
# File 'lib/conjur/policy/yaml/handler.rb', line 50

def start_sequence anchor
  raise "Unexpected sequence"
end