Class: Valkyrie::Persistence::Solr::ResourceFactory
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Solr::ResourceFactory
- 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
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#resource_indexer ⇒ Object
readonly
Returns the value of attribute resource_indexer.
Instance Method Summary collapse
-
#from_resource(resource:) ⇒ Hash
The solr document represented as a hash.
-
#initialize(resource_indexer:, adapter:) ⇒ ResourceFactory
constructor
A new instance of ResourceFactory.
- #to_resource(object:) ⇒ Valkyrie::Resource
Constructor Details
#initialize(resource_indexer:, adapter:) ⇒ ResourceFactory
Returns a new instance of ResourceFactory.
13 14 15 16 |
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 13 def initialize(resource_indexer:, adapter:) @resource_indexer = resource_indexer @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 8 def adapter @adapter end |
#resource_indexer ⇒ Object (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.
27 28 29 |
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 27 def from_resource(resource:) Valkyrie::Persistence::Solr::ModelConverter.new(resource, resource_factory: self).convert! end |
#to_resource(object:) ⇒ Valkyrie::Resource
21 22 23 |
# File 'lib/valkyrie/persistence/solr/resource_factory.rb', line 21 def to_resource(object:) ORMConverter.new(object, resource_factory: self).convert! end |