Sha256: d224eb3fc6d801586408f41b2db04db580492acfca788874c7af8c81ea9545f7
Contents?: true
Size: 1.22 KB
Versions: 51
Compression:
Stored size: 1.22 KB
Contents
module Scrivito class ObjCreateParamsParser < Struct.new(:host, :port, :context) def parse(params) params = params.deep_dup convert_params(params) params end private def convert_params(params) if obj_class = params['_obj_class'] obj_class = Obj.type_computer.compute_type_without_fallback(obj_class) convert_field_params(params, obj_class.attribute_definitions) else raise ArgumentError, 'Missing "_obj_class" param' end end def convert_field_params(params, attribute_definitions) params.each_pair do |key, value| params[key] = case attribute_definitions[key.to_s].try(:type) when 'binary' then parse_binary_params(value) when 'html' then ContentConversion.convert_html_links(value, host, port) when 'link' then ContentConversion.convert_link(value, host, port) when 'linklist' then ContentConversion.convert_linklist_urls(value, host, port) when 'date' then DateConversion.deserialize_from_client(value) else value end end end def parse_binary_params(params) return unless params UploadedBinary.new(params) end end end
Version data entries
51 entries across 51 versions & 1 rubygems