Module: BravoGuard::Controller

Defined in:
lib/bravo_guard/controller.rb

Instance Method Summary collapse

Instance Method Details

#authorise!(options = {}) ⇒ Object

nodoc



5
6
7
8
9
# File 'lib/bravo_guard/controller.rb', line 5

def authorise!(options={})
  return if authoriser.allows?(current_user, *permission)
  err = authoriser.inspect
  raise BravoGuard::PermissionDenied, err
end

#authoriserObject

nodoc



13
14
15
16
17
# File 'lib/bravo_guard/controller.rb', line 13

def authoriser
  return resource_class.new if action_name == 'index'
  build_resource if ['new', 'create'].include?(action_name)
  resource
end

#permissionObject

nodoc



21
22
23
# File 'lib/bravo_guard/controller.rb', line 21

def permission
  action_name
end