Sha256: 033792c6aadf370251ef488733bd3f9771a503979876e9d14ac740a9bccf2936
Contents?: true
Size: 916 Bytes
Versions: 4
Compression:
Stored size: 916 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 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.nil?) or self.options[:validate] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems