Sha256: a29d43f79f90661bdb00cacda0584abe512d0e7aae618a4aa0e612c6d6fd503a

Contents?: true

Size: 637 Bytes

Versions: 5

Compression:

Stored size: 637 Bytes

Contents

require 'representable/binding'

module Representable
  module Hash
    class Binding < Representable::Binding
      def self.build_for(definition)
        return Collection.new(definition)  if definition.array?
        new(definition)
      end

      def read(hash, as)
        hash.has_key?(as) ? hash[as] : FragmentNotFound
      end

      def write(hash, fragment, as)
        hash[as] = fragment
      end

      def serialize_method
        :to_hash
      end

      def deserialize_method
        :from_hash
      end

      class Collection < self
        include Representable::Binding::Collection
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
representable-2.4.0.rc5 lib/representable/hash/binding.rb
representable-2.4.0.rc4 lib/representable/hash/binding.rb
representable-2.4.0.rc3 lib/representable/hash/binding.rb
representable-2.4.0.rc2 lib/representable/hash/binding.rb
representable-2.4.0.rc1 lib/representable/hash/binding.rb