Class: Psych::Pure::SafeEmitter
Overview
A safe emitter is a subclass of the emitter that restricts the types of objects that can be serialized.
Constant Summary collapse
- DEFAULT_PERMITTED_CLASSES =
{ TrueClass => true, FalseClass => true, NilClass => true, Integer => true, Float => true, String => true, Array => true, Hash => true, }.compare_by_identity.freeze
Instance Method Summary collapse
-
#initialize(io, options) ⇒ SafeEmitter
constructor
Initialize a new safe emitter with the given io and options.
Methods inherited from Emitter
Constructor Details
#initialize(io, options) ⇒ SafeEmitter
Initialize a new safe emitter with the given io and options.
4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 |
# File 'lib/psych/pure.rb', line 4765 def initialize(io, ) super(io, ) @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 |