Class: Valkyrie::Indexers::AccessControlsIndexer

Inherits:
Object
  • Object
show all
Defined in:
lib/valkyrie/indexers/access_controls_indexer.rb

Overview

Note:

This is used primarily with Solr

Provides an optional interface consistent with Hydra::AccessControls

This allows for storing access control information into an index

Examples:

Use in Solr Adapter with a CompositeIndexer


# insert into config/initializers/valkyrie.rb
Valkyrie::MetadataAdapter.register(
    Valkyrie::Persistence::Solr::MetadataAdapter.new(
        connection: Blacklight.default_index.connection,
        resource_indexer: Valkyrie::Persistence::Solr::CompositeIndexer.new(
            Valkyrie::Indexers::AccessControlsIndexer,
            Collection::TypeIndexer
        )
    ),
    :index_solr
)

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource:, config: default_config) ⇒ AccessControlsIndexer

Returns a new instance of AccessControlsIndexer.



26
27
28
29
# File 'lib/valkyrie/indexers/access_controls_indexer.rb', line 26

def initialize(resource:, config: default_config)
  @resource = resource
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



25
26
27
# File 'lib/valkyrie/indexers/access_controls_indexer.rb', line 25

def config
  @config
end

#resourceObject (readonly)

Returns the value of attribute resource.



25
26
27
# File 'lib/valkyrie/indexers/access_controls_indexer.rb', line 25

def resource
  @resource
end

Instance Method Details

#to_solrObject



31
32
33
34
35
36
37
38
39
# File 'lib/valkyrie/indexers/access_controls_indexer.rb', line 31

def to_solr
  return {} unless resource.respond_to?(:read_users)
  {
    config.fetch(:read_groups) => resource.read_groups,
    config.fetch(:read_users) => resource.read_users,
    config.fetch(:edit_users) => resource.edit_users,
    config.fetch(:edit_groups) => resource.edit_groups
  }
end