Module: Hydra::Ability
- Extended by:
- ActiveSupport::Concern
- Includes:
- Blacklight::AccessControls::Ability
- Included in:
- Ability, PolicyAwareAbility
- Defined in:
- lib/hydra/ability.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #create_permissions ⇒ Object
-
#custom_permissions ⇒ Object
Override custom permissions in your own app to add more permissions beyond what is defined by default.
- #discover_permissions ⇒ Object
-
#download_permissions ⇒ Object
Download permissions are exercised in Hydra::Controller::DownloadBehavior.
- #edit_permissions ⇒ Object
- #hydra_default_permissions ⇒ Object
- #initialize(user, options = {}) ⇒ Object
- #read_permissions ⇒ Object
Class Method Details
Instance Method Details
#create_permissions ⇒ Object
35 36 37 |
# File 'lib/hydra/ability.rb', line 35 def # no op -- this is automatically run as part of self.ability_logic. Override in your own Ability class to set default create permissions. end |
#custom_permissions ⇒ Object
Override custom permissions in your own app to add more permissions beyond what is defined by default.
81 82 |
# File 'lib/hydra/ability.rb', line 81 def end |
#discover_permissions ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/hydra/ability.rb', line 63 def super can :discover, ActiveFedora::Base do |obj| test_discover(obj.id) end end |
#download_permissions ⇒ Object
Download permissions are exercised in Hydra::Controller::DownloadBehavior
72 73 74 75 76 77 78 |
# File 'lib/hydra/ability.rb', line 72 def can :download, ActiveFedora::File do |file| parent_uri = file.uri.to_s.sub(/\/[^\/]*$/, '') parent_id = ActiveFedora::Base.uri_to_id(parent_uri) can? :read, parent_id # i.e, can download if can read parent resource end end |
#edit_permissions ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hydra/ability.rb', line 39 def # Loading an object from Fedora can be slow, so assume that if a string is passed, it's an object id can [:edit, :update, :destroy], String do |id| test_edit(id) end can [:edit, :update, :destroy], ActiveFedora::Base do |obj| test_edit(obj.id) end can [:edit, :update, :destroy], SolrDocument do |obj| cache.put(obj.id, obj) test_edit(obj.id) end end |
#hydra_default_permissions ⇒ Object
31 32 33 |
# File 'lib/hydra/ability.rb', line 31 def end |
#initialize(user, options = {}) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/hydra/ability.rb', line 23 def initialize(user, = {}) @current_user = user || Hydra::Ability.user_class.new # guest user (not logged in) @user = @current_user # just in case someone was using this in an override. Just don't. @options = @cache = Blacklight::AccessControls::PermissionsCache.new () end |
#read_permissions ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/hydra/ability.rb', line 55 def super can :read, ActiveFedora::Base do |obj| test_read(obj.id) end end |