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:



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

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

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

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