Module: Hyrax::WorkflowsHelper

Included in:
DownloadsController, FileSetsController, HyraxHelperBehavior
Defined in:
app/helpers/hyrax/workflows_helper.rb

Instance Method Summary collapse

Instance Method Details

#workflow_restriction?(object, ability: current_ability) ⇒ false, true

TODO:

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.

Note:

If the object responds to a :workflow_restriction?, we’ll use that answer.

Note:

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).

Parameters:

  • object (Object)
  • ability (Ability) (defaults to: current_ability)

Returns:

  • (false)

    when there are no applicable workflow restrictions

  • (true)

    when there is an applicable workflow restriction, and you likely want to not render something.

See Also:



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