Module: OperationsHelper

Included in:
Operations::EnforcedController
Defined in:
app/helpers/operations_helper.rb

Instance Method Summary collapse

Instance Method Details

#enforce(operation, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/operations_helper.rb', line 3

def enforce(operation, &block)
  operation = Operations.from_string(operation)
  return if operation.nil?
  if block_given?
    return capture(&block) if operation == :all
    return '' if operation == :nobody
    return capture(&block) if operation.accepts_scope?(current_user.named_scope)
    ''
  end
  ''
end