Class: Padrino::Admin::AccessControl::Authorization
- Defined in:
- padrino-admin/lib/padrino-admin/access_control.rb
Overview
Project Authorization Class.
Instance Attribute Summary collapse
-
#allowed ⇒ Object
readonly
Returns the value of attribute allowed.
-
#denied ⇒ Object
readonly
Returns the value of attribute denied.
-
#project_modules ⇒ Object
readonly
Returns the value of attribute project_modules.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
-
#allow(path) ⇒ Object
Allow a specified path.
-
#initialize(*roles) {|_self| ... } ⇒ Authorization
constructor
A new instance of Authorization.
-
#project_module(name, path, options = {}) ⇒ Object
Create a project module.
-
#protect(path) ⇒ Object
Protect access from.
Constructor Details
#initialize(*roles) {|_self| ... } ⇒ Authorization
Returns a new instance of Authorization.
132 133 134 135 136 137 138 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 132 def initialize(*roles, &block) @roles = roles @allowed = [] @denied = [] @project_modules = [] yield self end |
Instance Attribute Details
#allowed ⇒ Object (readonly)
Returns the value of attribute allowed.
130 131 132 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 130 def allowed @allowed end |
#denied ⇒ Object (readonly)
Returns the value of attribute denied.
130 131 132 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 130 def denied @denied end |
#project_modules ⇒ Object (readonly)
Returns the value of attribute project_modules.
130 131 132 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 130 def project_modules @project_modules end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
130 131 132 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 130 def roles @roles end |
Instance Method Details
#allow(path) ⇒ Object
Allow a specified path.
143 144 145 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 143 def allow(path) @allowed << path unless @allowed.include?(path) end |
#project_module(name, path, options = {}) ⇒ Object
Create a project module.
157 158 159 160 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 157 def project_module(name, path, ={}) allow(path) @project_modules << ProjectModule.new(name, path, ) end |
#protect(path) ⇒ Object
Protect access from.
150 151 152 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 150 def protect(path) @denied << path unless @denied.include?(path) end |