Sha256: f4eb0c30f00d084a1a86780f9196608d75761b1d2e2d0331184ac3d144432484

Contents?: true

Size: 690 Bytes

Versions: 15

Compression:

Stored size: 690 Bytes

Contents

module AWS
  module Record
    module Attributes
      class SerializedAttr < BaseAttr

        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

        def self.serialize obj, options = {}
          AWS::DynamoDB::Binary.new(Marshal.dump(obj))
        end

        # @api private
        def self.allow_set?
          false
        end

      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dyna_model-0.0.15 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.14 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.13 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.12 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.11 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.10 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.9 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.8 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.7 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.6 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.5 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.4 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.3 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.2 lib/dyna_model/aws/record/attributes/serialized_attr.rb
dyna_model-0.0.1 lib/dyna_model/aws/record/attributes/serialized_attr.rb