Class: Padrino::Admin::AccessControl::Authorization

Inherits:
Object
  • Object
show all
Defined in:
padrino-admin/lib/padrino-admin/access_control.rb

Overview

Project Authorization Class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*roles) {|_self| ... } ⇒ Authorization

Returns a new instance of Authorization.

Yields:

  • (_self)

Yield Parameters:



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

#allowedObject (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

#deniedObject (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_modulesObject (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

#rolesObject (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, options={})
  allow(path)
  @project_modules << ProjectModule.new(name, path, options)
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