flexible_accessibility 0.1.1.pre → 0.1.2.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/flexible_accessibility.gemspec +1 -1
- data/lib/flexible_accessibility/controller_methods.rb +12 -6
- metadata +3 -3
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.1.
|
18
|
+
gem.version = "0.1.2.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.1.
|
8
|
+
s.version = "0.1.2.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,37 +1,42 @@
|
|
1
1
|
module FlexibleAccessibility
|
2
2
|
module ControllerMethods
|
3
3
|
module ClassMethods
|
4
|
-
before_filter :check_access_to_resource
|
5
|
-
before_filter :check_if_authorized
|
6
4
|
|
5
|
+
#
|
7
6
|
def skip_authorization_on_resource
|
8
7
|
@authorized = true
|
9
8
|
end
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
#
|
11
|
+
def authorize *args
|
12
|
+
self.send :before_filter, :check_access_to_resource, *args
|
13
13
|
end
|
14
14
|
|
15
|
+
#
|
15
16
|
def current_action
|
16
17
|
path = ActionController::Routing::Routes.recognize_path request.env["PATH_INFO"]
|
17
18
|
@fa_path = [path[:controller], path[:action]]
|
18
19
|
end
|
19
20
|
|
21
|
+
#
|
20
22
|
def check_access_to_resource
|
21
23
|
if @actions.include current_action[1].to_sym
|
22
24
|
@authorized = true unless Permission.check_access "#{current_action[0]}##{current_action[1]}", current_action
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
28
|
+
#
|
26
29
|
def check_if_authorized
|
27
30
|
raise FlexibleAccessibility::AccessDeniedException unless @authorized
|
28
31
|
end
|
29
32
|
|
33
|
+
#
|
30
34
|
def has_access? controller, action
|
31
35
|
Permission.check_access "#{controller}##{action}", current_action
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
39
|
+
#
|
35
40
|
def self.included base
|
36
41
|
base.extend ClassMethods
|
37
42
|
base.helper_method has_access?
|
@@ -39,8 +44,9 @@ module FlexibleAccessibility
|
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
42
|
-
|
43
|
-
|
47
|
+
#
|
48
|
+
if defined? ActionController
|
49
|
+
ActionController.class_eval do
|
44
50
|
include FlexibleAccessibility::ControllerMethods
|
45
51
|
end
|
46
52
|
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: 961915972
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
9
|
+
- 2
|
10
10
|
- pre
|
11
|
-
version: 0.1.
|
11
|
+
version: 0.1.2.pre
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Sergey Awanesov
|