Sha256: 3206cc9855190301e340a3116b84c293bd610171c9b4d7648864715497163f83

Contents?: true

Size: 684 Bytes

Versions: 1

Compression:

Stored size: 684 Bytes

Contents

module Hari
  class Entity
    module Serialization
      module Hash

        def self.serialize(value, options = {})
          if value.blank?
            {}
          elsif value.respond_to?(:to_hash)
            value.to_hash
          elsif value.respond_to?(:to_h)
            value.to_h
          elsif value.respond_to?(:marshal_dump)
            value.marshal_dump
          else
            fail 'value not accepted as a Hash'
          end
        end

        def self.desserialize(value, options = {})
          value
        end

        def self.method_missing(method, *args, &block)
          ::Hash.send method, *args, &block
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hari-0.0.5 lib/hari/entity/serialization/hash.rb