Sha256: df71e7b3ea181cc412b6acec6b580aca4cfb2a6df850b6b1d0a48147db59cf55

Contents?: true

Size: 634 Bytes

Versions: 1

Compression:

Stored size: 634 Bytes

Contents

class RestModel
  class Property
    module Sender
      def to_source!(value, resource, options = {})
        source_value = begin
          translation.translate_to_source(serializer.desserialize(value), resource)
        rescue => exception
          raise exception if options[:fail]
        end

        source = {}
        path = source_path

        if path.any?
          last = path.pop
          key_source = path.inject(source) {|buffer, key| buffer[key] = {}; buffer[key]}
          key_source[last] = source_value
        else
          source.merge!(source_value)
        end

        source
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest_model-0.1.5 lib/rest_model/key/property/sender.rb