Module: Dynamoid::Undumping
- Defined in:
- lib/dynamoid/undumping.rb
Defined Under Namespace
Modules: UndumpHashHelper
Classes: ArrayUndumper, Base, BooleanUndumper, CustomTypeUndumper, DateTimeUndumper, DateUndumper, IntegerUndumper, MapUndumper, NumberUndumper, RawUndumper, SerializedUndumper, SetUndumper, StringUndumper
Class Method Summary
collapse
Class Method Details
.find_undumper(options) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/dynamoid/undumping.rb', line 28
def self.find_undumper(options)
undumper_class = case options[:type]
when :string then StringUndumper
when :integer then IntegerUndumper
when :number then NumberUndumper
when :set then SetUndumper
when :array then ArrayUndumper
when :map then MapUndumper
when :datetime then DateTimeUndumper
when :date then DateUndumper
when :raw then RawUndumper
when :serialized then SerializedUndumper
when :boolean then BooleanUndumper
when Class then CustomTypeUndumper
end
if undumper_class.present?
undumper_class.new(options)
end
end
|
.undump_attributes(attributes, attributes_options) ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/dynamoid/undumping.rb', line 5
def self.undump_attributes(attributes, attributes_options)
{}.tap do |h|
attributes.symbolize_keys
.select { |attribute| attributes_options.key?(attribute) }
.each do |attribute, value|
h[attribute] = undump_field(value, attributes_options[attribute])
end
end
end
|
.undump_field(value, options) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/dynamoid/undumping.rb', line 16
def self.undump_field(value, options)
return nil if value.nil?
undumper = find_undumper(options)
if undumper.nil?
raise ArgumentError, "Unknown type #{options[:type]}"
end
undumper.process(value)
end
|