Class: Paquito::SafeYAML::RestrictedYAMLTree
- Inherits:
-
Psych::Visitors::YAMLTree
- Object
- Psych::Visitors::YAMLTree
- Paquito::SafeYAML::RestrictedYAMLTree
- Defined in:
- lib/paquito/safe_yaml.rb
Defined Under Namespace
Classes: DispatchCache
Instance Method Summary collapse
- #dump_coder(target) ⇒ Object
-
#initialize ⇒ RestrictedYAMLTree
constructor
A new instance of RestrictedYAMLTree.
- #permitted_class?(klass) ⇒ Boolean
Constructor Details
#initialize ⇒ RestrictedYAMLTree
Returns a new instance of RestrictedYAMLTree.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/paquito/safe_yaml.rb', line 65 def initialize(*) super @permitted_classes = Set.new(@options[:permitted_classes]) @dispatch_cache = DispatchCache.new(self, @dispatch_cache) @permitted_cache = Hash.new do |h, klass| unless @permitted_classes.include?(klass.name) raise UnsupportedType, "Tried to dump unspecified class: #{klass.name.inspect}" end h[klass] = true end.compare_by_identity end |
Instance Method Details
#dump_coder(target) ⇒ Object
79 80 81 82 83 |
# File 'lib/paquito/safe_yaml.rb', line 79 def dump_coder(target) return unless permitted_class?(target.class) super end |
#permitted_class?(klass) ⇒ Boolean
85 86 87 |
# File 'lib/paquito/safe_yaml.rb', line 85 def permitted_class?(klass) @permitted_cache[klass] end |