Module: Dynamoid::TypeCasting
- Defined in:
- lib/dynamoid/type_casting.rb
Defined Under Namespace
Classes: ArrayTypeCaster, Base, BinaryTypeCaster, BooleanTypeCaster, CustomTypeCaster, DateTimeTypeCaster, DateTypeCaster, IntegerTypeCaster, MapTypeCaster, NumberTypeCaster, RawTypeCaster, SerializedTypeCaster, SetTypeCaster, StringTypeCaster
Class Method Summary
collapse
Class Method Details
.cast_attributes(attributes, attributes_options) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/dynamoid/type_casting.rb', line 6
def self.cast_attributes(attributes, attributes_options)
{}.tap do |h|
attributes.symbolize_keys.each do |attribute, value|
h[attribute] = cast_field(value, attributes_options[attribute])
end
end
end
|
.cast_field(value, options) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/dynamoid/type_casting.rb', line 14
def self.cast_field(value, options)
return value if options.nil?
return nil if value.nil?
type_caster = find_type_caster(options)
if type_caster.nil?
raise ArgumentError, "Unknown type #{options[:type]}"
end
type_caster.process(value)
end
|
.find_type_caster(options) ⇒ Object