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

#initialize(rules = []) ⇒ AuthorizationRuleSet

Returns a new instance of AuthorizationRuleSet.



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

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

Instance Method Details

#<<(rule) ⇒ Object



412
413
414
415
# File 'lib/declarative_authorization/authorization.rb', line 412

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

#delete(rule) ⇒ Object



407
408
409
410
# File 'lib/declarative_authorization/authorization.rb', line 407

def delete(rule)
  @rules.delete rule
  reset!
end

#each(&block) ⇒ Object



417
418
419
# File 'lib/declarative_authorization/authorization.rb', line 417

def each(&block)
  @rules.each &block
end

#initialize_copy(source) ⇒ Object



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

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

#matching(roles, privileges, context) ⇒ Object



400
401
402
403
404
405
# File 'lib/declarative_authorization/authorization.rb', line 400

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