Sha256: 2df73c67cd601d323afd5b942545b55ba1eaac44e8de202651993e06c82ddb06
Contents?: true
Size: 933 Bytes
Versions: 3
Compression:
Stored size: 933 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, self.options) rescue TranslationError, SerializationError => error raise error if options[:fail] and validates?(value) 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 private def validates?(value) (self.options[:validate_if_present] and value.present?) or self.options[:validate] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rest_model-0.3.1 | lib/rest_model/key/property/sender.rb |
rest_model-0.3.0 | lib/rest_model/key/property/sender.rb |
rest_model-0.2.3 | lib/rest_model/key/property/sender.rb |