Module: Sufia::Permissions::Writable

Extended by:
ActiveSupport::Concern
Includes:
Hydra::AccessControls::Permissions, Hydra::AccessControls::Visibility
Included in:
GenericFile::Permissions
Defined in:
lib/sufia/permissions/writable.rb

Instance Method Summary collapse

Instance Method Details

#paranoid_permissionsObject



15
16
17
18
19
# File 'lib/sufia/permissions/writable.rb', line 15

def paranoid_permissions
  # let the rightsMetadata ds make this determination
  # - the object instance is passed in for easier access to the props ds
  .validate(self)
end

#permissionsObject



33
34
35
36
# File 'lib/sufia/permissions/writable.rb', line 33

def permissions
  perms = super
  perms.map {|p| { name: p.name, access: p.access, type:p.type } }
end

#permissions=(params) ⇒ Object

Updates those permissions that are provided to it. Does not replace any permissions unless they are provided



22
23
24
25
26
27
28
29
30
31
# File 'lib/sufia/permissions/writable.rb', line 22

def permissions=(params)
  perm_hash = permission_hash
  params[:new_user_name].each { |name, access| perm_hash['person'][name] = access } if params[:new_user_name].present?
  params[:new_group_name].each { |name, access| perm_hash['group'][name] = access } if params[:new_group_name].present?

  params[:user].each { |name, access| perm_hash['person'][name] = access} if params[:user]
  params[:group].each { |name, access| perm_hash['group'][name] = access if ['read', 'edit'].include?(access)} if params[:group]

  .update_permissions(perm_hash)
end