Module: Authorule::Rule::ClassMethods

Defined in:
lib/authorule/rule.rb

Overview

Rule creation accessors

Instance Method Summary collapse

Instance Method Details

#allow(kind, name, attributes = {}) ⇒ Object

Builds an allow rule for the given kind and name.



40
41
42
# 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 = {}) ⇒ Object

Creates an allow rule for the given kind and name.



45
46
47
# File 'lib/authorule/rule.rb', line 45

def allow!(kind, name, attributes = {})
  allow(kind, name, attributes).save
end

#allow_all(kind = :all, attributes = {}) ⇒ Object

Builds an ‘allow all’ rule.

Examples

Rule.allow_all              # => kind 'all', name 'all'
Rule.allow_all(:resource)   # => kind 'resource', name 'all'


65
66
67
# 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 = {}) ⇒ Object

Creates an ‘allow all’ rule.

See Also:



71
72
73
# File 'lib/authorule/rule.rb', line 71

def allow_all!(kind = :all, attributes = {})
  allow_all(kind, attributes).save
end

#deny(kind, name, attributes = {}) ⇒ Object

Builds a deny rule for the given kind and name.



50
51
52
# 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 = {}) ⇒ Object

Creates a deny rule for the given kind and name.



55
56
57
# File 'lib/authorule/rule.rb', line 55

def deny!(kind, name, attributes = {})
  deny(kind, name, attributes).save
end

#deny_all(kind = :all, attributes = {}) ⇒ Object

Creates a ‘deny all’ rule.

Examples

Rule.deny_all              # => kind 'all', name 'all'
Rule.deny_all(:resource)   # => kind 'resource', name 'all'


81
82
83
# 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 = {}) ⇒ Object

Creates an ‘deny all’ rule.

See Also:



87
88
89
# File 'lib/authorule/rule.rb', line 87

def deny_all!(kind = :all, attributes = {})
  allow_all(kind, attributes).save
end