flexible_accessibility 0.2.6.pre → 0.2.7.pre
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ require 'jeweler'
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
17
|
gem.name = "flexible_accessibility"
|
18
|
-
gem.version = "0.2.
|
18
|
+
gem.version = "0.2.7.pre"
|
19
19
|
gem.homepage = "http://github.com/mochnatiy/flexible_accessibility"
|
20
20
|
gem.license = "MIT"
|
21
21
|
gem.summary = %Q{Flexible access control system}
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "flexible_accessibility"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.7.pre"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sergey Awanesov"]
|
@@ -1,21 +1,29 @@
|
|
1
1
|
module FlexibleAccessibility
|
2
2
|
class Permission
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :resource
|
4
4
|
attr_reader :actions
|
5
5
|
|
6
6
|
def initialize args={}
|
7
|
-
@
|
7
|
+
@resource = args[:resource]
|
8
8
|
@actions = args[:actions]
|
9
9
|
end
|
10
10
|
|
11
|
+
def controller
|
12
|
+
ApplicationResource.new(self.resource).controller
|
13
|
+
end
|
14
|
+
|
15
|
+
def namespace
|
16
|
+
ApplicationResource.new(self.resource).namespace
|
17
|
+
end
|
18
|
+
|
11
19
|
class << self
|
12
20
|
def all
|
13
21
|
permissions = []
|
14
22
|
Utils.new.get_controllers.each do |scope|
|
15
23
|
namespace = scope.first
|
16
|
-
(scope - namespace.to_a).each do |
|
17
|
-
|
18
|
-
permissions << Permission.new(:
|
24
|
+
(scope - namespace.to_a).each do |resource|
|
25
|
+
resource = "#{namespace}::#{resource}" unless namespace == "default"
|
26
|
+
permissions << Permission.new(:resource => resource.gsub(/_controller/, "").to_sym, :actions => ApplicationResource.new(resource).klass.instance_variable_get(:@_checkable_routes))
|
19
27
|
end
|
20
28
|
end
|
21
29
|
permissions
|
@@ -1,15 +1,20 @@
|
|
1
1
|
module FlexibleAccessibility
|
2
2
|
class ApplicationResource
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :controller
|
4
4
|
attr_reader :namespace
|
5
5
|
|
6
6
|
def initialize resource_string
|
7
|
-
@
|
7
|
+
@controller = resource_string.split("::").last
|
8
8
|
@namespace = resource_string.split("::").first
|
9
9
|
end
|
10
10
|
|
11
11
|
def klass
|
12
|
-
(@namespace.camelize + "::" + @
|
12
|
+
(@namespace.camelize + "::" + @controller.camelize).constantize unless is_standard_resource?
|
13
|
+
@controller.camelize.constantize if is_standard_resource?
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_standard_resource?
|
17
|
+
@namespace == "default"
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexible_accessibility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -1231723782
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
9
|
+
- 7
|
10
10
|
- pre
|
11
|
-
version: 0.2.
|
11
|
+
version: 0.2.7.pre
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Sergey Awanesov
|