Class: CurrentScope::PermissionCatalog

Inherits:
Object
  • Object
show all
Defined in:
lib/current_scope/permission_catalog.rb

Overview

Derives the permission set from the host's routes: one permission per controller#action pair. There is no table to maintain — add a controller and its actions appear in the grid on next boot/reload.

Instance Method Summary collapse

Instance Method Details

#groupedObject

{ "reports" => ["approve", "create", ...], ... } for the role-editor grid.



11
12
13
14
# File 'lib/current_scope/permission_catalog.rb', line 11

def grouped
  keys.group_by { |key| key.split("#").first }
      .transform_values { |ks| ks.map { |k| k.split("#").last } }
end

#include?(key) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/current_scope/permission_catalog.rb', line 16

def include?(key)
  keys.include?(key)
end

#keysObject



6
7
8
# File 'lib/current_scope/permission_catalog.rb', line 6

def keys
  @keys ||= derive
end