lib/rest_model/key/property/sender.rb in rest_model-0.1.4 vs lib/rest_model/key/property/sender.rb in rest_model-0.1.5

- old
+ new

@@ -1,17 +1,11 @@ class RestModel class Property module Sender def to_source!(value, resource, options = {}) - source_value = nil - - begin - if translations - source_value = translate_to_source(value, resource) - else - source_value = serializer.desserialize(value) - end + source_value = begin + translation.translate_to_source(serializer.desserialize(value), resource) rescue => exception raise exception if options[:fail] end source = {} @@ -24,18 +18,9 @@ else source.merge!(source_value) end source - end - - def translate_to_source(value, resource) - case translations - when Proc then resource.instance_eval(&translations) - when Hash - fail "to input error" unless translations.has_key?(value) - translations[value] - end end end end end