Sha256: 4f8e5135282fa919e800c809678521bd46843ca505bb6dadf75538178f9f8162

Contents?: true

Size: 721 Bytes

Versions: 5

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  ##
  # A module of form behaviours for populating permissions.
  module PermissionBehavior
    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

    # https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
    def permission_populator(collection:, index:, **)
      Hyrax::Forms::Permission.new(collection[index])
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hyrax-5.0.3 app/forms/concerns/hyrax/permission_behavior.rb
hyrax-5.0.2 app/forms/concerns/hyrax/permission_behavior.rb
hyrax-5.0.1 app/forms/concerns/hyrax/permission_behavior.rb
hyrax-5.0.0 app/forms/concerns/hyrax/permission_behavior.rb
hyrax-5.0.0.rc3 app/forms/concerns/hyrax/permission_behavior.rb