Sha256: 50b8cfb1f8895709e3f7fa07be24348e7576bbc7acbf895eff63910adb755924

Contents?: true

Size: 1.19 KB

Versions: 47

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
module Valkyrie::Persistence::Solr
  # Provides access to generic methods for converting to/from
  # {Valkyrie::Resource} and hashes for persistence into Solr.
  class ResourceFactory
    require 'valkyrie/persistence/solr/orm_converter'
    require 'valkyrie/persistence/solr/model_converter'
    attr_reader :resource_indexer, :adapter
    delegate :id, to: :adapter, prefix: true

    # @param [Valkyrie::Persistence::Solr::MetadataAdapter::NullIndexer] resource_indexer
    # @param [Valkyrie::Persistence::Solr::MetadataAdapter] adapter
    def initialize(resource_indexer:, adapter:)
      @resource_indexer = resource_indexer
      @adapter = adapter
    end

    # @param object [Hash] The solr document in a hash to convert to a
    #   resource.
    # @return [Valkyrie::Resource]
    def to_resource(object:)
      ORMConverter.new(object, resource_factory: self).convert!
    end

    # @param resource [Valkyrie::Resource] The resource to convert to a solr hash.
    # @return [Hash] The solr document represented as a hash.
    def from_resource(resource:)
      Valkyrie::Persistence::Solr::ModelConverter.new(resource, resource_factory: self).convert!
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
valkyrie-3.5.0 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.4.0 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.3.0 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.1.5 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.1.4 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.1.3 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.1.2 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.1.1 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.1.0 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.3 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.2 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.1 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.0 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.0.pre.rc.1 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.0.pre.beta.3 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.0.pre.beta.2 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-3.0.0.pre.beta.1 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-2.2.0 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-2.1.2 lib/valkyrie/persistence/solr/resource_factory.rb
valkyrie-2.1.1 lib/valkyrie/persistence/solr/resource_factory.rb