module Authorule::Rule::ClassMethods

Rule creation accessors

Public Instance Methods

allow(kind, name, attributes = {}) click to toggle source

Builds an allow rule for the given kind and name.

# File lib/authorule/rule.rb, line 40
def allow(kind, name, attributes = {})
  new attributes.merge(:kind => kind, :name => name, :allow => true)
end
allow!(kind, name, attributes = {}) click to toggle source

Creates an allow rule for the given kind and name.

# File lib/authorule/rule.rb, line 45
def allow!(kind, name, attributes = {})
  allow(kind, name, attributes).save
end
allow_all(kind = :all, attributes = {}) click to toggle source

Builds an ‘allow all’ rule.

Examples

Rule.allow_all              # => kind 'all', name 'all'
Rule.allow_all(:resource)   # => kind 'resource', name 'all'
# File lib/authorule/rule.rb, line 65
def allow_all(kind = :all, attributes = {})
  new attributes.merge(:kind => kind, :name => 'all', :allow => true)
end
allow_all!(kind = :all, attributes = {}) click to toggle source

Creates an ‘allow all’ rule. @see .allow_all

# File lib/authorule/rule.rb, line 71
def allow_all!(kind = :all, attributes = {})
  allow_all(kind, attributes).save
end
deny(kind, name, attributes = {}) click to toggle source

Builds a deny rule for the given kind and name.

# File lib/authorule/rule.rb, line 50
def deny(kind, name, attributes = {})
  new attributes.merge(:kind => kind, :name => name, :allow => false)
end
deny!(kind, name, attributes = {}) click to toggle source

Creates a deny rule for the given kind and name.

# File lib/authorule/rule.rb, line 55
def deny!(kind, name, attributes = {})
  deny(kind, name, attributes).save
end
deny_all(kind = :all, attributes = {}) click to toggle source

Creates a ‘deny all’ rule.

Examples

Rule.deny_all              # => kind 'all', name 'all'
Rule.deny_all(:resource)   # => kind 'resource', name 'all'
# File lib/authorule/rule.rb, line 81
def deny_all(kind = :all, attributes = {})
  new attributes.merge(:kind => kind, :name => 'all', :allow => false)
end
deny_all!(kind = :all, attributes = {}) click to toggle source

Creates an ‘deny all’ rule. @see .deny_all

# File lib/authorule/rule.rb, line 87
def deny_all!(kind = :all, attributes = {})
  allow_all(kind, attributes).save
end