Class: Dynamoid::Undumping::SerializedUndumper

Inherits:
Base
  • Object
show all
Defined in:
lib/dynamoid/undumping.rb

Constant Summary collapse

YAML_SAFE_LOAD =

Once we drop support for Rubies older than 2.6 we can remove this conditional (with major version bump)! YAML_SAFE_LOAD = minimum_ruby_version.call(“2.6”) But we don’t want to change behavior for Ruby <= 3.0 that has been using the gem, without a major version bump

minimum_ruby_version.call('3.1')

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dynamoid::Undumping::Base

Instance Method Details

#process(value) ⇒ Object



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/dynamoid/undumping.rb', line 246

def process(value)
  if @options[:serializer]
    @options[:serializer].load(value)
  elsif YAML_SAFE_LOAD
    # The classes listed in permitted classes are added to the default set of "safe loadable" classes.
    # TrueClass
    # FalseClass
    # NilClass
    # Integer
    # Float
    # String
    # Array
    # Hash
    YAML.safe_load(value, permitted_classes: [Symbol, Set, Date, Time, DateTime])
  else
    YAML.load(value)
  end
end