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:



136
137
138
139
140
141
142
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 136

def initialize(*roles, &block)
  @roles           = roles
  @allowed         = []
  @denied          = []
  @project_modules = []
  yield self
end

Instance Attribute Details

#allowedObject (readonly)

Returns the value of attribute allowed



134
135
136
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 134

def allowed
  @allowed
end

#deniedObject (readonly)

Returns the value of attribute denied



134
135
136
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 134

def denied
  @denied
end

#project_modulesObject (readonly)

Returns the value of attribute project_modules



134
135
136
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 134

def project_modules
  @project_modules
end

#rolesObject (readonly)

Returns the value of attribute roles



134
135
136
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 134

def roles
  @roles
end

Instance Method Details

#allow(path) ⇒ Object

Allow a specified path.



147
148
149
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 147

def allow(path)
  @allowed << path unless @allowed.include?(path)
end

#project_module(name, path, options = {}) ⇒ Object

Create a project module.



161
162
163
164
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 161

def project_module(name, path, options={})
  allow(path)
  @project_modules << ProjectModule.new(name, path, options)
end

#protect(path) ⇒ Object

Protect access from.



154
155
156
# File 'padrino-admin/lib/padrino-admin/access_control.rb', line 154

def protect(path)
  @denied << path unless @denied.include?(path)
end