Class: Conjur::Policy::YAML::Handler::Mapping
- Defined in:
- lib/conjur/policy/yaml/handler.rb
Overview
Handles a mapping, each of which will be parsed into a structured record.
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
Instance Method Summary collapse
-
#alias(anchor) ⇒ Object
Begins a mapping with the anchor value as the key.
- #end_mapping ⇒ Object
-
#initialize(parent, anchor, type) ⇒ Mapping
constructor
A new instance of Mapping.
- #map_entry(key, value) ⇒ Object
-
#scalar(value, tag, quoted, anchor) ⇒ Object
Begins a new map entry.
Methods inherited from Base
#end_sequence, #handler, #pop_handler, #push_handler, #start_mapping, #start_sequence
Constructor Details
#initialize(parent, anchor, type) ⇒ Mapping
Returns a new instance of Mapping.
203 204 205 206 207 |
# File 'lib/conjur/policy/yaml/handler.rb', line 203 def initialize parent, anchor, type super parent, anchor @record = type.new end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
201 202 203 |
# File 'lib/conjur/policy/yaml/handler.rb', line 201 def type @type end |
Instance Method Details
#alias(anchor) ⇒ Object
Begins a mapping with the anchor value as the key.
223 224 225 226 227 228 |
# File 'lib/conjur/policy/yaml/handler.rb', line 223 def alias anchor key = handler.anchor(anchor) MapEntry.new(self, nil, @record, key).tap do |h| h.push_handler end end |
#end_mapping ⇒ Object
238 239 240 241 242 |
# File 'lib/conjur/policy/yaml/handler.rb', line 238 def end_mapping parent.mapping @record handler.anchor anchor, @record if anchor pop_handler end |
#map_entry(key, value) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/conjur/policy/yaml/handler.rb', line 209 def map_entry key, value handler.log { "#{handler.indent}Setting map entry #{key} = #{value}" } if @record.respond_to?(:[]=) @record.send(:[]=, key, value) else begin @record.send("#{key}=", value) rescue NoMethodError raise "No such attribute '#{key}' on type #{@record.class.short_name}" end end end |
#scalar(value, tag, quoted, anchor) ⇒ Object
Begins a new map entry.
231 232 233 234 235 236 |
# File 'lib/conjur/policy/yaml/handler.rb', line 231 def scalar value, tag, quoted, anchor value = scalar_value(value, tag, quoted, type) MapEntry.new(self, anchor, @record, value).tap do |h| h.push_handler end end |