flexible_accessibility 0.1.3.pre → 0.1.6.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
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.6.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.6.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"]
|
@@ -5,20 +5,23 @@ module FlexibleAccessibility
|
|
5
5
|
# Macro for skip authorization
|
6
6
|
def skip_authorization_here
|
7
7
|
self.instance_variable_set :@route_permitted, true
|
8
|
+
self.instance_variable_set :@checkable_routes, []
|
8
9
|
self.send :before_filter, :check_if_route_permitted
|
9
10
|
end
|
10
11
|
|
11
12
|
# Macro for define authorization
|
12
13
|
def authorize args={}
|
14
|
+
self.instance_variable_set :@route_permitted, false
|
13
15
|
self.send :before_filter, :check_permission_to_route
|
14
16
|
self.send :before_filter, :check_if_route_permitted
|
15
|
-
set_actions_to_authorize
|
17
|
+
set_actions_to_authorize args
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
19
21
|
#
|
20
22
|
def set_actions_to_authorize args={}
|
21
23
|
self.instance_variable_set :@checkable_routes, args[:only] unless args[:only].nil?
|
24
|
+
# TODO: understand and fix it
|
22
25
|
self.instance_variable_set :@checkable_routes, self.action_methods - args[:except] unless args[:except].nil?
|
23
26
|
end
|
24
27
|
|
@@ -41,13 +44,13 @@ module FlexibleAccessibility
|
|
41
44
|
raise FlexibleAccessibility::AccessDeniedException unless self.instance_variable_get :@route_permitted
|
42
45
|
end
|
43
46
|
end
|
44
|
-
|
47
|
+
|
45
48
|
# Callback needs for include methods and define helper method
|
46
49
|
def self.included base
|
47
|
-
|
48
|
-
|
50
|
+
base.extend ClassMethods
|
51
|
+
base.helper_method :has_access?
|
49
52
|
end
|
50
|
-
|
53
|
+
|
51
54
|
# We checks url for each link in view to show it
|
52
55
|
def has_access? controller, action
|
53
56
|
Permissions.is_action_permitted_for_user? "#{controller}##{action}", current_user
|
@@ -56,8 +59,8 @@ module FlexibleAccessibility
|
|
56
59
|
end
|
57
60
|
|
58
61
|
#
|
59
|
-
if defined? ActionController
|
60
|
-
ActionController.class_eval do
|
62
|
+
if defined? ActionController::Base
|
63
|
+
ActionController::Base.class_eval do
|
61
64
|
include FlexibleAccessibility::ControllerMethods
|
62
65
|
end
|
63
66
|
end
|
@@ -4,7 +4,7 @@ module FlexibleAccessibility
|
|
4
4
|
def get_permissions
|
5
5
|
permissions = {}
|
6
6
|
ApplicationController.subclasses.each do |klass|
|
7
|
-
permissions[klass.to_s.tableize.singularize.to_sym] = klass.
|
7
|
+
permissions[klass.to_s.tableize.singularize.to_sym] = klass.instance_variable_get(:@checkable_routes).collect{ |a| a.to_s }.join(', ')
|
8
8
|
end
|
9
9
|
permissions
|
10
10
|
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: 961915988
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
9
|
+
- 6
|
10
10
|
- pre
|
11
|
-
version: 0.1.
|
11
|
+
version: 0.1.6.pre
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Sergey Awanesov
|