Class: Valkyrie::Persistence::Solr::ResourceFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/valkyrie/persistence/solr/resource_factory.rb

Overview

Provides access to generic methods for converting to/from Resource and hashes for persistence into Solr.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_indexer:) ⇒ ResourceFactory

Returns a new instance of ResourceFactory.



9
10
11
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 9

def initialize(resource_indexer:)
  @resource_indexer = resource_indexer
end

Instance Attribute Details

#resource_indexerObject (readonly)

Returns the value of attribute resource_indexer.



8
9
10
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 8

def resource_indexer
  @resource_indexer
end

Instance Method Details

#from_resource(resource:) ⇒ Hash

Returns The solr document represented as a hash.

Parameters:

Returns:

  • (Hash)

    The solr document represented as a hash.



22
23
24
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 22

def from_resource(resource:)
  Valkyrie::Persistence::Solr::ModelConverter.new(resource, resource_factory: self).convert!
end

#to_resource(object:) ⇒ Valkyrie::Resource

Parameters:

  • object (Hash)

    The solr document in a hash to convert to a resource.

Returns:



16
17
18
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 16

def to_resource(object:)
  ORMConverter.new(object).convert!
end