Class: Valkyrie::Persistence::Fedora::Persister::ResourceFactory

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#adapterObject (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

Returns:



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

Returns:

  • (LDP::Container::Basic)

    object



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