Module: Authorization

Defined in:
lib/role-authz/authorization/authorization.rb,
lib/role-authz/authorization/controller_helper.rb

Defined Under Namespace

Modules: OperatorMixin Classes: ControllerHelper, NoCurrentForRoleStatement, OpenForRoleStatement

Class Method Summary collapse

Class Method Details

.add_role(name, &block) ⇒ Object



14
15
16
# File 'lib/role-authz/authorization/authorization.rb', line 14

def self.add_role(name, &block)
  @roles[name] = block
end

.roles_for(operator, target) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/role-authz/authorization/authorization.rb', line 4

def self.roles_for(operator, target)
  list = []
  @roles.each do |name, proc|
    if proc.call(operator, target)
      list += [name]
    end
  end
  list
end