Sha256: 6d3de736d82137bc8b72b467e3593ae6676255bd4cb7582fd66f290f1042d235

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

module DataMapper
  module Mongo
    class Property
      class Hash < DataMapper::Property::Object
        include DataMapper::Property::PassThroughLoadDump
        primitive ::Hash

        # @api semipublic
        def load(value)
          typecast_to_primitive(value)
        end

        # @api semipublic
        def typecast_to_primitive(value)
          case value
          when NilClass
            nil
          when ::Hash
            DataMapper::Ext::Hash.to_mash(value).symbolize_keys
          when ::Array
            value.empty? ? {} : {value.first.to_sym => value.last}
          end
        end
      end #Array
    end # Property
  end # Mongo
end # DataMapper

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-mongo-adapter-0.6.0 lib/mongo_adapter/property/hash.rb