Class: Wings::NestedResourceMapper

Inherits:
Valkyrie::ValueMapper
  • Object
show all
Defined in:
lib/wings/transformer_value_mapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handles?(value) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/wings/transformer_value_mapper.rb', line 17

def self.handles?(value)
  value.is_a? Wings::ActiveFedoraConverter::NestedResource
end

Instance Method Details

#resultObject



21
22
23
24
25
26
27
28
# File 'lib/wings/transformer_value_mapper.rb', line 21

def result
  attributes = value.attributes.symbolize_keys
  nested_object = Wings::ActiveFedoraConverter::NestedResource.new(attributes)
  klass = Wings::ModelTransformer::ResourceClassCache.instance.fetch(Wings::ActiveFedoraConverter::NestedResource) do
    OrmConverter.to_valkyrie_resource_class(klass: nested_object.class)
  end
  klass.new(attributes)
end