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=(params) ⇒ Object
Updates those permissions that are provided to it.
- #merged_policies ⇒ Object
- #to_solr(solr_doc = Hash.new) ⇒ Object
Instance Method Details
#default_permissions=(params) ⇒ Object
Updates those permissions that are provided to it. Does not replace any permissions unless they are provided
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/concerns/hydra/admin_policy_behavior.rb', line 39 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 |
#merged_policies ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/hydra/admin_policy_behavior.rb', line 24 def merged_policies # Workaround for https://github.com/projecthydra/active_fedora/issues/775 .to_a.uniq.each_with_object({}) do |, h| args = .to_hash h[args[:access]] ||= {} h[args[:access]][args[:type]] ||= [] h[args[:access]][args[:type]] << args[:name] end end |
#to_solr(solr_doc = Hash.new) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/concerns/hydra/admin_policy_behavior.rb', line 10 def to_solr(solr_doc=Hash.new) f = merged_policies super.tap do |doc| ['discover'.freeze, 'read'.freeze, 'edit'.freeze].each do |access| doc[Hydra.config..inheritable[access.to_sym][:group]] = f[access]['group'.freeze] if f[access] doc[Hydra.config..inheritable[access.to_sym][:individual]] = f[access]['person'.freeze] if f[access] end if key = Hydra.config..inheritable..release_date.sub(/_[^_]+$/, '') #Strip off the suffix ::Solrizer.insert_field(doc, key, ., :stored_sortable) end end end |