Module: Sufia::GenericFile::Permissions

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

Instance Method Summary collapse

Instance Method Details

#paranoid_permissionsObject



14
15
16
17
18
# File 'lib/sufia/models/generic_file/permissions.rb', line 14

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



32
33
34
35
# File 'lib/sufia/models/generic_file/permissions.rb', line 32

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



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

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