Module: Sufia::GenericFile::Permissions
- Extended by:
- ActiveSupport::Concern
- Includes:
- Hydra::ModelMixins::RightsMetadata
- Included in:
- Sufia::GenericFile
- Defined in:
- lib/sufia/generic_file/permissions.rb
Instance Method Summary collapse
- #paranoid_permissions ⇒ Object
-
#permissions=(params) ⇒ Object
Updates those permissions that are provided to it.
- #set_visibility(visibility) ⇒ Object
Instance Method Details
#paranoid_permissions ⇒ Object
28 29 30 31 32 |
# File 'lib/sufia/generic_file/permissions.rb', line 28 def # let the rightsMetadata ds make this determination # - the object instance is passed in for easier access to the props ds rightsMetadata.validate(self) end |
#permissions=(params) ⇒ Object
Updates those permissions that are provided to it. Does not replace any permissions unless they are provided
35 36 37 38 39 40 41 42 43 |
# File 'lib/sufia/generic_file/permissions.rb', line 35 def (params) perm_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 params[:group] rightsMetadata.(perm_hash) end |
#set_visibility(visibility) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sufia/generic_file/permissions.rb', line 13 def set_visibility(visibility) # only set explicit permissions case visibility when "open" self.datastreams["rightsMetadata"].({:group=>"public"}, "read") when "psu" self.datastreams["rightsMetadata"].({:group=>"registered"}, "read") self.datastreams["rightsMetadata"].({:group=>"public"}, "none") when "restricted" self.datastreams["rightsMetadata"].({:group=>"registered"}, "none") self.datastreams["rightsMetadata"].({:group=>"public"}, "none") end end |