Module: Hydra::AdminPolicyBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- AdminPolicy
- Defined in:
- app/models/concerns/hydra/admin_policy_behavior.rb
Instance Method Summary collapse
-
#default_permissions ⇒ Object
Returns a list with all the permissions on the object.
-
#default_permissions=(params) ⇒ Object
Updates those permissions that are provided to it.
Instance Method Details
#default_permissions ⇒ Object
Returns a list with all the permissions on the object.
34 35 36 37 |
# File 'app/models/concerns/hydra/admin_policy_behavior.rb', line 34 def (defaultRights.groups.map {|x| {:type=>'group', :access=>x[1], :name=>x[0] }} + defaultRights.users.map {|x| {:type=>'user', :access=>x[1], :name=>x[0]}}) end |
#default_permissions=(params) ⇒ Object
Updates those permissions that are provided to it. Does not replace any permissions unless they are provided
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/concerns/hydra/admin_policy_behavior.rb', line 13 def (params) perm_hash = {'person' => defaultRights.users, 'group'=> defaultRights.groups} params.each do |row| if row[:type] == 'user' || row[:type] == 'person' perm_hash['person'][row[:name]] = row[:access] elsif row[:type] == 'group' perm_hash['group'][row[:name]] = row[:access] else raise ArgumentError, "Permission type must be 'user', 'person' (alias for 'user'), or 'group'" end end defaultRights.(perm_hash) end |