Class: Wings::Valkyrie::ResourceFactory
- Inherits:
-
Object
- Object
- Wings::Valkyrie::ResourceFactory
- Defined in:
- lib/wings/valkyrie/resource_factory.rb
Overview
This class provides two-way mapping between ‘ActiveFedora::Base` and `Valkyrie::Resource` models.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#from_resource(resource:) ⇒ ActiveFedora::Base
ActiveFedora resource for the Valkyrie resource.
-
#initialize(adapter:) ⇒ ResourceFactory
constructor
A new instance of ResourceFactory.
-
#to_resource(object:) ⇒ Valkyrie::Resource
Model representation of the AF record.
Constructor Details
#initialize(adapter:) ⇒ ResourceFactory
Returns a new instance of ResourceFactory.
23 24 25 |
# File 'lib/wings/valkyrie/resource_factory.rb', line 23 def initialize(adapter:) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
17 18 19 |
# File 'lib/wings/valkyrie/resource_factory.rb', line 17 def adapter @adapter end |
Instance Method Details
#from_resource(resource:) ⇒ ActiveFedora::Base
Returns ActiveFedora resource for the Valkyrie resource.
40 41 42 |
# File 'lib/wings/valkyrie/resource_factory.rb', line 40 def from_resource(resource:) ActiveFedoraConverter.new(resource: resource).convert end |
#to_resource(object:) ⇒ Valkyrie::Resource
Returns Model representation of the AF record.
31 32 33 |
# File 'lib/wings/valkyrie/resource_factory.rb', line 31 def to_resource(object:) object.valkyrie_resource end |