Sha256: b3dc0edfbc616e27f8f77f70a041910d20ecf3d4a6c461a9b5f95b37ea90f41f

Contents?: true

Size: 714 Bytes

Versions: 12

Compression:

Stored size: 714 Bytes

Contents

module Representable
  module Object
    class Binding < Representable::Binding
      def self.build_for(definition)  # TODO: remove default arg.
        return Collection.new(definition)  if definition.array?
        new(definition)
      end

      def read(hash, as)
        fragment = hash.send(as) # :getter? no, that's for parsing!

        return FragmentNotFound if fragment.nil? and typed?
        fragment
      end

      def write(hash, fragment, as)
        true
      end

      def deserialize_method
        :from_object
      end

      def serialize_method
        :to_object
      end


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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
representable-3.0.4 lib/representable/object/binding.rb
representable-3.0.3 lib/representable/object/binding.rb
representable-3.0.2 lib/representable/object/binding.rb
representable-3.0.1 lib/representable/object/binding.rb
representable-3.0.0 lib/representable/object/binding.rb
representable-2.4.1 lib/representable/object/binding.rb
representable-2.4.0 lib/representable/object/binding.rb
representable-2.4.0.rc5 lib/representable/object/binding.rb
representable-2.4.0.rc4 lib/representable/object/binding.rb
representable-2.4.0.rc3 lib/representable/object/binding.rb
representable-2.4.0.rc2 lib/representable/object/binding.rb
representable-2.4.0.rc1 lib/representable/object/binding.rb