Sha256: 02cdd49d53c966be0d9e6ec6b6877fb207c9a28dd3f58d43a94bbb399c218d4c

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

require "representable/deserializer"

module Representable
  class ObjectSerializer < ObjectDeserializer
    def initialize(binding, object)
      super(binding)
      @object = object
    end

    def call
      # return unless @binding.typed? # FIXME: fix that in XML/YAML.
      return @object if @object.nil? # DISCUSS: move to Object#serialize ?

      representable = prepare(@object)

      serialize(representable, @binding.user_options)
    end

  private
    def serialize(object, user_options)
      return object unless @binding.representable?

      object.send(@binding.serialize_method, user_options.merge!({:wrap => false}))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
representable-1.8.0 lib/representable/serializer.rb