Class: Psych::Visitors::RestrictedYAMLTree
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
Psych::Visitors::YAMLTree
|
Defined in: | ext/psych/lib/psych/visitors/yaml_tree.rb |
Constant Summary
-
DEFAULT_PERMITTED_CLASSES =
# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 538{ TrueClass => true, FalseClass => true, NilClass => true, Integer => true, Float => true, String => true, Array => true, Hash => true, }.compare_by_identity.freeze
Class Method Summary
- .new(emitter, ss, options) ⇒ RestrictedYAMLTree constructor
YAMLTree
- Inherited
Visitor
- Inherited
Instance Attribute Summary
YAMLTree
- Inherited
#finished? | Alias for YAMLTree#finished. |
#started? | Alias for YAMLTree#started. |
Instance Method Summary
YAMLTree
- Inherited
Visitor
- Inherited
Constructor Details
.new(emitter, ss, options) ⇒ RestrictedYAMLTree
# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 549
def initialize emitter, ss, super @permitted_classes = DEFAULT_PERMITTED_CLASSES.dup Array( [:permitted_classes]).each do |klass| @permitted_classes[klass] = true end @permitted_symbols = {}.compare_by_identity Array( [:permitted_symbols]).each do |symbol| @permitted_symbols[symbol] = true end @aliases = .fetch(:aliases, false) end
Instance Method Details
#accept(target)
[ GitHub ]# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 562
def accept target if !@aliases && @st.key?(target) raise BadAlias, "Tried to dump an aliased object" end unless Symbol === target || @permitted_classes[target.class] raise DisallowedClass.new('dump', target.class.name || target.class.inspect) end super end
#visit_Symbol(sym)
[ GitHub ]# File 'ext/psych/lib/psych/visitors/yaml_tree.rb', line 574
def visit_Symbol sym unless @permitted_classes[Symbol] || @permitted_symbols[sym] raise DisallowedClass.new('dump', "Symbol(#{sym.inspect})") end super end