Class: Authorization::AuthorizationRuleSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/declarative_authorization/authorization.rb

Instance Method Summary (collapse)

Constructor Details

- (AuthorizationRuleSet) initialize(rules = [])



369
370
371
372
# File 'lib/declarative_authorization/authorization.rb', line 369

def initialize (rules = [])
  @rules = rules.clone
  reset!
end

Instance Method Details

- (Object) <<(rule)



390
391
392
393
# File 'lib/declarative_authorization/authorization.rb', line 390

def << rule
  @rules << rule
  reset!
end

- (Object) delete(rule)



386
387
388
389
# File 'lib/declarative_authorization/authorization.rb', line 386

def delete rule
  @rules.delete rule
  reset!
end

- (Object) each(&block)



394
395
396
# File 'lib/declarative_authorization/authorization.rb', line 394

def each &block
  @rules.each &block
end

- (Object) initialize_copy(source)



374
375
376
377
# File 'lib/declarative_authorization/authorization.rb', line 374

def initialize_copy (source)
  @rules = @rules.collect {|rule| rule.clone}
  reset!
end

- (Object) matching(roles, privileges, context)



379
380
381
382
383
384
385
# File 'lib/declarative_authorization/authorization.rb', line 379

def matching(roles, privileges, context)
  roles = [roles] unless roles.is_a?(Array)
  rules = cached_auth_rules[context] || []
  rules.select do |rule|
    rule.matches? roles, privileges, context
  end
end