Sha256: 4f210e581cd728ebf5495ee50b640a9f67e528d79a0e4c1fddc299be82e98bc0

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

class RestModel
  class Property
    module Sender
      def to_source!(value, resource, options = {})
        source_value = begin
          translation.translates_to_source? ? translation.translate_to_source(value, resource)
                                            : serializer.desserialize(value)
        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.6 lib/rest_model/key/property/sender.rb