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, type) ⇒ Mapping
constructor
A new instance of Mapping.
- #map_entry(key, value) ⇒ Object
- #result ⇒ Object
-
#scalar(value, tag, quoted) ⇒ 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, type) ⇒ Mapping
Returns a new instance of Mapping.
205 206 207 208 209 |
# File 'lib/conjur/policy/yaml/handler.rb', line 205 def initialize parent, type super parent @record = type.new end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
203 204 205 |
# File 'lib/conjur/policy/yaml/handler.rb', line 203 def type @type end |
Instance Method Details
#alias(anchor) ⇒ Object
Begins a mapping with the anchor value as the key.
226 227 228 229 230 231 |
# File 'lib/conjur/policy/yaml/handler.rb', line 226 def alias anchor key = handler.anchor(anchor) MapEntry.new(self, @record, key).tap do |h| h.push_handler end.result end |
#end_mapping ⇒ Object
241 242 243 244 |
# File 'lib/conjur/policy/yaml/handler.rb', line 241 def end_mapping parent.mapping @record pop_handler end |
#map_entry(key, value) ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/conjur/policy/yaml/handler.rb', line 213 def 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 |
#result ⇒ Object
211 |
# File 'lib/conjur/policy/yaml/handler.rb', line 211 def result; @record; end |