Module: YamledAcl
- Defined in:
- lib/yamled_acl.rb,
lib/yamled_acl/version.rb,
lib/yamled_acl/exceptions.rb,
lib/yamled_acl/controller_extension.rb
Defined Under Namespace
Modules: ControllerExtension Classes: AccessDenied, Error, NotExistingGroup, UninitializedGroup, UninitializedResource
Constant Summary collapse
- ALLOW_ALL =
'allow_all'
- DENY_ALL =
'deny_all'
- VERSION =
"0.3.1"
Class Attribute Summary collapse
-
.files_with_permissions_path ⇒ Object
Returns the value of attribute files_with_permissions_path.
-
.groups ⇒ Object
Returns the value of attribute groups.
-
.guest_group_name ⇒ Object
Returns the value of attribute guest_group_name.
-
.reload_permissions_on_each_request ⇒ Object
Returns the value of attribute reload_permissions_on_each_request.
Class Method Summary collapse
-
.init(group_name, resource_name) ⇒ Object
Initializes ACL by giving logged user group name and currently processed resource name.
-
.permission?(action, resource = nil) ⇒ Boolean
Method used for checking permissions.
-
.setup {|_self| ... } ⇒ Object
Provides configuration options:.
Class Attribute Details
.files_with_permissions_path ⇒ Object
Returns the value of attribute files_with_permissions_path.
12 13 14 |
# File 'lib/yamled_acl.rb', line 12 def @files_with_permissions_path end |
.groups ⇒ Object
Returns the value of attribute groups.
14 15 16 |
# File 'lib/yamled_acl.rb', line 14 def groups @groups end |
.guest_group_name ⇒ Object
Returns the value of attribute guest_group_name.
15 16 17 |
# File 'lib/yamled_acl.rb', line 15 def guest_group_name @guest_group_name end |
.reload_permissions_on_each_request ⇒ Object
Returns the value of attribute reload_permissions_on_each_request.
13 14 15 |
# File 'lib/yamled_acl.rb', line 13 def @reload_permissions_on_each_request end |
Class Method Details
.init(group_name, resource_name) ⇒ Object
Initializes ACL by giving logged user group name and currently processed resource name.
40 41 42 43 44 |
# File 'lib/yamled_acl.rb', line 40 def self.init(group_name, resource_name) init_resource(resource_name) init_group(group_name) (Thread.current[:yamled_acl_resource_name]) end |
.permission?(action, resource = nil) ⇒ Boolean
Method used for checking permissions. Optional resource name may be specified to check permission for other resource than curently processed.
48 49 50 51 52 53 54 55 56 |
# File 'lib/yamled_acl.rb', line 48 def self.(action, resource = nil) Thread.current.key?(:yamled_acl_group) or raise(UninitializedGroup) if resource.nil? check(@actions_permissions[Thread.current[:yamled_acl_resource_name]][action.to_s]) else (resource) check(@actions_permissions[resource.to_s][action.to_s]) end end |
.setup {|_self| ... } ⇒ Object
Provides configuration options:
YamledAcl.setup do |config|
config. = 'other/than/default/path'
config. = Rails.env.development?
config.groups = %w(admin member)
config.guest_group_name = 'visitor'
end
33 34 35 36 |
# File 'lib/yamled_acl.rb', line 33 def self.setup yield(self) @groups << @guest_group_name end |