Class: Conjur::Policy::YAML::Handler::MapEntry

Inherits:
Base
  • Object
show all
Defined in:
lib/conjur/policy/yaml/handler.rb

Overview

Processes a map entry. At this point, the parent record and the map key are known.

Instance Attribute Summary collapse

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Base

#end_mapping, #end_sequence, #handler, #pop_handler, #push_handler

Constructor Details

#initialize(parent, record, key) ⇒ MapEntry

Returns a new instance of MapEntry.



251
252
253
254
255
256
# File 'lib/conjur/policy/yaml/handler.rb', line 251

def initialize parent, record, key
  super parent
  
  @record = record
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



249
250
251
# File 'lib/conjur/policy/yaml/handler.rb', line 249

def key
  @key
end

#recordObject (readonly)

Returns the value of attribute record.



249
250
251
# File 'lib/conjur/policy/yaml/handler.rb', line 249

def record
  @record
end

Instance Method Details

#alias(anchor) ⇒ Object

Interpret the alias as the map value and populate in the parent.



274
275
276
# File 'lib/conjur/policy/yaml/handler.rb', line 274

def alias anchor
  value handler.anchor(anchor)
end

#mapping(value) ⇒ Object



264
265
266
# File 'lib/conjur/policy/yaml/handler.rb', line 264

def mapping value
  value value
end

#resultObject



258
# File 'lib/conjur/policy/yaml/handler.rb', line 258

def result; nil; end

#scalar(value, tag, quoted) ⇒ Object



297
298
299
# File 'lib/conjur/policy/yaml/handler.rb', line 297

def scalar value, tag, quoted
  value scalar_value(value, tag, quoted, yaml_field_type(key))
end

#sequence(value) ⇒ Object



260
261
262
# File 'lib/conjur/policy/yaml/handler.rb', line 260

def sequence value
  value value
end

#start_mapping(tag) ⇒ Object

Start a mapping as a map value.



279
280
281
282
283
284
285
286
287
288
# File 'lib/conjur/policy/yaml/handler.rb', line 279

def start_mapping tag
  if type = type_of(tag, yaml_field_type(key))
    Mapping.new(self, type).tap do |h|
      h.push_handler
    end.result
  else
    # We got a mapping on a simple type
    raise "Attribute '#{key}' can't be a mapping"
  end
end

#start_sequenceObject

Start a sequence as a map value.



291
292
293
294
295
# File 'lib/conjur/policy/yaml/handler.rb', line 291

def start_sequence
  Sequence.new(self, yaml_field_type(key)).tap do |h|
    h.push_handler
  end.result
end

#value(value) ⇒ Object



268
269
270
271
# File 'lib/conjur/policy/yaml/handler.rb', line 268

def value value
  parent.map_entry @key, value
  pop_handler
end