Module: Hyrax::AdminSetBehavior
- Extended by:
- ActiveSupport::Concern
- Includes:
- Hydra::AccessControls::WithAccessRight, HasRepresentative, HumanReadableType, Noid
- Included in:
- AdminSet
- Defined in:
- app/models/concerns/hyrax/admin_set_behavior.rb
Overview
There is an interplay between an AdminSet and a PermissionTemplate. Given that AdminSet is an ActiveFedora::Base and PermissionTemplate is ActiveRecord::Base we don’t have the usual :has_many or :belongs_to methods to assist in defining that relationship. However, from a conceptual standpoint:
-
An AdminSet has_one :permission_tempate
-
A PermissionTemplate belongs_to :admin_set
When an object is added as a member of an AdminSet, the AdminSet’s associated PermissionTemplate is applied to that object (e.g. some of the object’s attributes are updated as per the rules of the permission template)
Instance Method Summary collapse
- #active_workflow ⇒ Sipity::Workflow
-
#permission_template ⇒ Hyrax::PermissionTemplate
A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB.
- #to_s ⇒ Object
-
#update_access_controls! ⇒ Object
Calculate and update who should have edit access based on who has “manage” access in the PermissionTemplateAccess.
Methods included from HumanReadableType
#human_readable_type, #to_solr
Methods included from Noid
Instance Method Details
#active_workflow ⇒ Sipity::Workflow
87 88 89 |
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 87 def active_workflow Sipity::Workflow.find_active_workflow_for(admin_set_id: id) end |
#permission_template ⇒ Hyrax::PermissionTemplate
A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB
79 80 81 |
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 79 def Hyrax::PermissionTemplate.find_by!(admin_set_id: id) end |
#to_s ⇒ Object
71 72 73 |
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 71 def to_s title.present? ? title : 'No Title' end |
#update_access_controls! ⇒ Object
Calculate and update who should have edit access based on who has “manage” access in the PermissionTemplateAccess
93 94 95 96 |
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 93 def update_access_controls! update!(edit_users: .agent_ids_for(access: 'manage', agent_type: 'user'), edit_groups: .agent_ids_for(access: 'manage', agent_type: 'group')) end |