module Operation::Worker::FileMarshaller::ClassMethods
Public Instance Methods
file_marshaller_representer()
click to toggle source
# File lib/trailblazer/operation/worker.rb, line 81 def file_marshaller_representer @file_marshaller_representer ||= contract_class.schema(include: [Representable::Hash]).apply do |dfn| dfn.merge!( getter: lambda { |*| self[dfn.name.to_sym] }, setter: lambda { |fragment, *| self[dfn.name.to_s] = fragment } ) # FIXME: allow both sym and str. dfn.merge!(class: Hash) and next if dfn[:form] or dfn[:twin] # nested properties need a class for deserialization. next unless dfn[:file] # TODO: where do we set /tmp/uploads? dfn.merge!( serialize: lambda { |file, *| Trailblazer::Operation::UploadedFile.new(file, tmp_dir: "/tmp/uploads").to_hash }, deserialize: lambda { |object, hash, *| Trailblazer::Operation::UploadedFile.from_hash(hash) }, class: Hash ) end end
serializable(params)
click to toggle source
# File lib/trailblazer/operation/worker.rb, line 100 def serializable(params) file_marshaller_representer.new(params).to_hash end