328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
# File 'lib/dynamoid/dirty.rb', line 328
def self.dup_attribute(value, type_options)
type, of = type_options.values_at(:type, :of)
case value
when NilClass, TrueClass, FalseClass, Numeric, Symbol, IO
value
when Array
if of.is_a? Class
value.map { |e| dup_attribute(e, type: of) }
else
value.deep_dup
end
when Set
Set.new(value.map { |e| dup_attribute(e, type: of) })
else
if type.is_a? Class
dump = Dumping.dump_field(value, type_options)
Undumping.undump_field(dump.deep_dup, type_options)
else
value.deep_dup
end
end
end
|