Sha256: 6c7e8d1462fa9f00f3bf9f0f8e142fb5f8cf06d787e34d5dfba24c8ffdb59bd7

Contents?: true

Size: 615 Bytes

Versions: 5

Compression:

Stored size: 615 Bytes

Contents

ActiveFedora::QueryMethods.module_eval do
  extend ActiveSupport::Concern

  def accessible_by(ability, action = :index)
    permission_types = case action
      when :index then [:discover, :read, :edit]
      when :show, :read then [:read, :edit]
      when :update, :edit, :create, :new, :destroy then [:edit]
    end

    builder = Hydra::SearchBuilder.new(nil).with_ability(ability).with_discovery_permissions(permission_types)
    filters = builder.send(:gated_discovery_filters).join(" OR ")
    spawn.where!(filters)
  end
end

ActiveFedora::Querying.module_eval do
  delegate :accessible_by, :to=>:all
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hydra-access-controls-13.0.0 lib/active_fedora/accessible_by.rb
hydra-access-controls-12.1.0 lib/active_fedora/accessible_by.rb
hydra-access-controls-12.0.2 lib/active_fedora/accessible_by.rb
hydra-access-controls-12.0.1 lib/active_fedora/accessible_by.rb
hydra-access-controls-12.0.0 lib/active_fedora/accessible_by.rb