Sha256: d2a8181118550c7d91d97fd17376a7d7dfa6bd10cc1d0fd001fbd40ddf03aac8
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
class RestModel class Embeddable module Sender def to_source!(value, resource, options = {}) return {} if value.nil? fields ? to_multiple_source(value, options) : to_single_source(value, options) end private def to_single_source(value, options) source = {} path = source_path if path.any? last = path.pop key_source = path.inject(source) {|buffer, key| buffer[key] = {}; buffer[key]} key_source[last] = raw? ? value : one? ? value.to_source(options) : value.map {|item| item.to_source(options)} else source.merge!(value.to_source(options)) end source end def to_multiple_source(value, options) input = {} mapped_fields = convert_input_keys.call(fields) value.each_with_index do |item, index| input[mapped_fields[index]] = item end input end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rest_model-0.1.19 | lib/rest_model/key/embeddable/sender.rb |
rest_model-0.1.18 | lib/rest_model/key/embeddable/sender.rb |