Class: AWS::Record::Attributes::SerializedAttr

Inherits:
BaseAttr
  • Object
show all
Defined in:
lib/dyna_model/aws/record/attributes/date_time_attr.rb,
lib/dyna_model/aws/record/attributes/serialized_attr.rb

Class Method Summary collapse

Class Method Details

.allow_set?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


26
27
28
# File 'lib/dyna_model/aws/record/attributes/serialized_attr.rb', line 26

def self.allow_set?
  false
end

.serialize(obj, options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/dyna_model/aws/record/attributes/date_time_attr.rb', line 9

def self.serialize datetime, options = {}
  unless datetime.is_a?(DateTime) || datetime.is_a?(Time)
    msg = "expected a DateTime value, got #{datetime.class}"
    raise ArgumentError, msg
  end
  datetime.strftime('%Y-%m-%dT%H:%M:%S%Z')
end

.type_cast(raw_value, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dyna_model/aws/record/attributes/serialized_attr.rb', line 6

def self.type_cast raw_value, options = {}
  case raw_value
  when nil      then nil
  when ''       then nil
  when String # assume binary
    begin
      Marshal.load(raw_value)
    rescue
      raw_value
    end
  else # object to serialize
    raw_value
  end
end