Module: Hyrax::WorkflowsHelper
- Included in:
- DownloadsController, FileSetsController, HyraxHelperBehavior
- Defined in:
- app/helpers/hyrax/workflows_helper.rb
Instance Method Summary collapse
-
#workflow_restriction?(object, ability: current_ability) ⇒ false, true
Does a workflow restriction exist for the given :object and given :ability?.
Instance Method Details
#workflow_restriction?(object, ability: current_ability) ⇒ false, true
As I noodle on this, I’m fairly certain we should be registering a CanCan ability check. I believe in promoting this to a helper method it will be easier to incorporate this into an ability.
If the object responds to a :workflow_restriction?, we’ll use that answer.
This is Jeremy, I encourage you to look at the views that call this method to understand the conceptual space this method covers.
Does a workflow restriction exist for the given :object and given :ability?
This method doesn’t answer what kind of restriction is in place (that requires a far more nuanced permissioning system than Hyrax presently has). Instead, it answers is there one in place. From that answer, you may opt out of rendering a region on a view (e.g. don’t show links to the edit page).
34 35 36 37 38 39 40 |
# File 'app/helpers/hyrax/workflows_helper.rb', line 34 def workflow_restriction?(object, ability: current_ability) return false if object.nil? # Yup, we may get nil, and there's no restriction on nil return object.workflow_restriction? if object.respond_to?(:workflow_restriction?) return false if ability.can?(:edit, object) return object.suppressed? if object.respond_to?(:suppressed?) false end |