module Rack::Authorize::Ability

Public Instance Methods

can(method, path, &block) click to toggle source
# File lib/rack/authorize/ability.rb, line 3
def can(method, path, &block)
  rules << Rule.new(method, path, block)
end
can?(method, path) click to toggle source
# File lib/rack/authorize/ability.rb, line 7
def can?(method, path)
  matched_rules(method, path).each do |rule|
    return rule.block.call if rule.block
    return true
  end
  false
end

Private Instance Methods

matched_rules(method, path) click to toggle source
# File lib/rack/authorize/ability.rb, line 30
def matched_rules(method, path)
  rules.select {|rule| rule.relevant?(method, path)}
end
rules() click to toggle source
# File lib/rack/authorize/ability.rb, line 26
def rules
  @rules ||= []
end