Module: Hyrax::Ability

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/hyrax/ability.rb,
app/models/concerns/hyrax/ability/admin_set_ability.rb,
app/models/concerns/hyrax/ability/collection_ability.rb,
app/models/concerns/hyrax/ability/solr_document_ability.rb,
app/models/concerns/hyrax/ability/collection_type_ability.rb,
app/models/concerns/hyrax/ability/permission_template_ability.rb

Defined Under Namespace

Modules: AdminSetAbility, CollectionAbility, CollectionTypeAbility, PermissionTemplateAbility, SolrDocumentAbility

Instance Method Summary collapse

Instance Method Details

#admin?Boolean

Override this method in your ability model if you use a different group or other logic to designate an administrator.

Returns:

  • (Boolean)

65
66
67
# File 'app/models/concerns/hyrax/ability.rb', line 65

def admin?
  user_groups.include? admin_group_name
end

#can_create_any_work?Boolean

Returns true if can create at least one type of work and they can deposit into at least one AdminSet

Returns:

  • (Boolean)

57
58
59
60
61
# File 'app/models/concerns/hyrax/ability.rb', line 57

def can_create_any_work?
  Hyrax.config.curation_concerns.any? do |curation_concern_type|
    can?(:create, curation_concern_type)
  end && admin_set_with_deposit?
end

#download_groups(id) ⇒ Object

Samvera doesn't use download user/groups, so make it an alias to read Grant all groups with read or edit access permission to download


38
39
40
41
42
43
44
# File 'app/models/concerns/hyrax/ability.rb', line 38

def download_groups(id)
  doc = permissions_doc(id)
  return [] if doc.nil?
  groups = Array(doc[self.class.read_group_field]) + Array(doc[self.class.edit_group_field])
  Rails.logger.debug("[CANCAN] download_groups: #{groups.inspect}")
  groups
end

#download_users(id) ⇒ Object

Grant all users with read or edit access permission to download


47
48
49
50
51
52
53
# File 'app/models/concerns/hyrax/ability.rb', line 47

def download_users(id)
  doc = permissions_doc(id)
  return [] if doc.nil?
  users = Array(doc[self.class.read_user_field]) + Array(doc[self.class.edit_user_field])
  Rails.logger.debug("[CANCAN] download_users: #{users.inspect}")
  users
end