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.
133 134 135 136 137 138 139 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 133 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.
131 132 133 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 131 def allowed @allowed end |
#denied ⇒ Object (readonly)
Returns the value of attribute denied.
131 132 133 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 131 def denied @denied end |
#project_modules ⇒ Object (readonly)
Returns the value of attribute project_modules.
131 132 133 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 131 def project_modules @project_modules end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
131 132 133 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 131 def roles @roles end |
Instance Method Details
#allow(path) ⇒ Object
Allow a specified path.
144 145 146 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 144 def allow(path) @allowed << path unless @allowed.include?(path) end |
#project_module(name, path, options = {}) ⇒ Object
Create a project module.
158 159 160 161 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 158 def project_module(name, path, = {}) allow(path) @project_modules << ProjectModule.new(name, path, ) end |
#protect(path) ⇒ Object
Protect access from.
151 152 153 |
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 151 def protect(path) @denied << path unless @denied.include?(path) end |