52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/wings/attribute_transformer.rb', line 52
def run(obj)
keys = obj.metadata_node.class.fields
attributes = keys.each_with_object({}) do |attr_name, mem|
next unless obj.respond_to?(attr_name) && !mem.key?(attr_name.to_sym)
mem[attr_name.to_sym] = TransformerValueMapper.for(obj.public_send(attr_name)).result
end
attributes[:original_filename] = obj.original_name
if obj.id.present?
uri = Hyrax.config.translate_id_to_uri.call(obj.id)
attributes[:file_identifier] = Wings::Valkyrie::Storage.cast_to_valkyrie_id(uri)
end
attributes[:type] = obj.metadata_node.type.to_a
attributes[:size] = obj.size
attributes
end
|