lib/property/parse_file.rb in dm-parse-0.3.1 vs lib/property/parse_file.rb in dm-parse-0.3.2
- old
+ new
@@ -2,24 +2,26 @@
class Property
class ParseFile < Object
def dump(value)
- if value.is_a?(Hash)
- value.merge("__type" => "File")
- elsif value.respond_to?(:original_filename) && value.respond_to?(:read) && value.respond_to?(:content_type)
+ value
+ end
+
+ def load(value)
+ value
+ end
+
+ def typecast(value)
+ if value.respond_to?(:original_filename) && value.respond_to?(:read) && value.respond_to?(:content_type)
adapter = model.repository.adapter
filename = value.original_filename
content = value.read
content_type = value.content_type
- dump adapter.upload_file(filename, content, content_type)
+ adapter.upload_file(filename, content, content_type).merge("__type" => "File")
else
- nil
+ value
end
- end
-
- def load(value)
- value
end
end
end