Sha256: 052558ff810475157d9429d369df9e008e2b675cf465633a865c989b6a2c80e2

Contents?: true

Size: 812 Bytes

Versions: 8

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Forms
    ##
    # Nested form for permissions.
    #
    # @note due to historical oddities with Hydra::AccessControls and Hydra
    #   Editor, Hyrax's views rely on `agent_name` and `access` as field
    #   names. we provide these as virtual fields and prepopulate these from
    #   `Hyrax::Permission`.
    class Permission < Hyrax::ChangeSet
      property :agent_name, virtual: true, prepopulator: proc { |_opts| self.agent_name = model.agent }
      property :access, virtual: true, prepopulator: proc { |_opts| self.access = model.mode }

      ##
      # @note support a {#to_hash} method for compatibility with
      #   {Hydra::AccessControl::Permissions}
      def to_hash
        { name: agent_name, access: access }
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/forms/hyrax/forms/permission.rb
hyrax-5.0.0 app/forms/hyrax/forms/permission.rb
hyrax-5.0.0.rc3 app/forms/hyrax/forms/permission.rb
hyrax-5.0.0.rc2 app/forms/hyrax/forms/permission.rb
hyrax-5.0.0.rc1 app/forms/hyrax/forms/permission.rb
hyrax-4.0.0 app/forms/hyrax/forms/permission.rb
hyrax-4.0.0.rc3 app/forms/hyrax/forms/permission.rb
hyrax-4.0.0.rc2 app/forms/hyrax/forms/permission.rb