Sha256: 8c4bae20cb0461b5f5b2b3898b9cb854061193e6f79765c606f6c6b66b0c0f5e

Contents?: true

Size: 750 Bytes

Versions: 5

Compression:

Stored size: 750 Bytes

Contents

require 'representable/binding'

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

5 entries across 5 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/representable-3.2.0/lib/representable/object/binding.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/representable-3.2.0/lib/representable/object/binding.rb
representable-3.2.0 lib/representable/object/binding.rb
representable-3.1.1 lib/representable/object/binding.rb
representable-3.1.0 lib/representable/object/binding.rb