Sha256: 50d38e09f693b6b237f05791ab660fd57966482fcffea24a4449f1b86b092064
Contents?: true
Size: 919 Bytes
Versions: 3
Compression:
Stored size: 919 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.present?) or self.options[:validate] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rest_model-0.2.1 | lib/rest_model/key/property/sender.rb |
rest_model-0.2.0 | lib/rest_model/key/property/sender.rb |
rest_model-0.1.24 | lib/rest_model/key/property/sender.rb |