Module: Hyrax::PermissionBehavior

Included in:
Forms::FileSetForm, Forms::PcdmObjectForm, Forms::ResourceBatchEditForm
Defined in:
app/forms/concerns/hyrax/permission_behavior.rb

Overview

A module of form behaviours for populating permissions.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(descendant) ⇒ Object



6
7
8
9
10
11
12
13
# File 'app/forms/concerns/hyrax/permission_behavior.rb', line 6

def self.included(descendant)
  descendant.collection(:permissions,
             virtual: true,
             default: [],
             form: Hyrax::Forms::Permission,
             populator: :permission_populator,
             prepopulator: proc { |_opts| self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
end

Instance Method Details

#permission_populator(collection:, index:) ⇒ Object



16
17
18
# File 'app/forms/concerns/hyrax/permission_behavior.rb', line 16

def permission_populator(collection:, index:, **)
  Hyrax::Forms::Permission.new(collection[index])
end