Class: Valkyrie::Persistence::Fedora::Persister::ResourceFactory
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Fedora::Persister::ResourceFactory
- Defined in:
- lib/valkyrie/persistence/fedora/persister/resource_factory.rb
Overview
Provides access to generic methods for converting to/from Resource and LDP::Container::Basic.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#from_resource(resource:) ⇒ Valkyrie::Resource
Construct a LDP::Container::Basic object for a Valkyrie Resource.
-
#initialize(adapter:) ⇒ ResourceFactory
constructor
A new instance of ResourceFactory.
-
#to_resource(object:) ⇒ LDP::Container::Basic
Construct a Valkyrie::Resource object for a Valkyrie Resource.
Constructor Details
#initialize(adapter:) ⇒ ResourceFactory
Returns a new instance of ResourceFactory.
12 13 14 |
# File 'lib/valkyrie/persistence/fedora/persister/resource_factory.rb', line 12 def initialize(adapter:) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/valkyrie/persistence/fedora/persister/resource_factory.rb', line 9 def adapter @adapter end |
Instance Method Details
#from_resource(resource:) ⇒ Valkyrie::Resource
Construct a LDP::Container::Basic object for a Valkyrie Resource
18 19 20 |
# File 'lib/valkyrie/persistence/fedora/persister/resource_factory.rb', line 18 def from_resource(resource:) ModelConverter.new(resource: resource, adapter: adapter).convert end |
#to_resource(object:) ⇒ LDP::Container::Basic
Construct a Valkyrie::Resource object for a Valkyrie Resource
24 25 26 |
# File 'lib/valkyrie/persistence/fedora/persister/resource_factory.rb', line 24 def to_resource(object:) OrmConverter.new(object: object, adapter: adapter).convert end |