flexible_accessibility 0.1.8.pre → 0.1.95.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.1.
|
18
|
+
gem.version = "0.1.95.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,11 +5,11 @@
|
|
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.95.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"]
|
12
|
-
s.date = "2012-07-
|
12
|
+
s.date = "2012-07-18"
|
13
13
|
s.description = "Flexible access control system for your rails application. Based on analysis of controller actions"
|
14
14
|
s.email = "sergey.awanesov@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -6,14 +6,11 @@ module FlexibleAccessibility
|
|
6
6
|
def skip_authorization_here
|
7
7
|
self.instance_variable_set :@_route_permitted, true
|
8
8
|
self.instance_variable_set :@_checkable_routes, []
|
9
|
-
#self.send :before_filter, :check_if_route_permitted
|
10
9
|
end
|
11
10
|
|
12
11
|
# Macro for define authorization
|
13
12
|
def authorize args={}
|
14
13
|
self.instance_variable_set :@_route_permitted, false
|
15
|
-
#self.send :before_filter, :check_permission_to_route
|
16
|
-
#self.send :before_filter, :check_if_route_permitted
|
17
14
|
set_actions_to_authorize args
|
18
15
|
end
|
19
16
|
|
@@ -33,13 +30,13 @@ module FlexibleAccessibility
|
|
33
30
|
end
|
34
31
|
|
35
32
|
# We checks url for each link in view to show it
|
36
|
-
def has_access?
|
37
|
-
Permission.is_action_permitted_for_user?
|
33
|
+
def has_access? permission, user
|
34
|
+
Permission.is_action_permitted_for_user? permission, user
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
42
|
-
#
|
39
|
+
# We include methods in ActionController::Base
|
43
40
|
if defined? ActionController::Base
|
44
41
|
ActionController::Base.class_eval do
|
45
42
|
include FlexibleAccessibility::ControllerMethods
|
@@ -1,21 +1,30 @@
|
|
1
1
|
module FlexibleAccessibility
|
2
2
|
class Permission
|
3
|
+
attr_reader :controller
|
4
|
+
attr_reader :actions
|
5
|
+
|
6
|
+
def initialize args={}
|
7
|
+
@controller = args[:controller]
|
8
|
+
@actions = args[:actions]
|
9
|
+
end
|
10
|
+
|
3
11
|
class << self
|
4
12
|
def all
|
5
|
-
permissions =
|
13
|
+
permissions = []
|
6
14
|
Utils.new.get_controllers.each do |klass|
|
7
|
-
permissions
|
15
|
+
permissions << Permission.new(:controller => klass.gsub(/_controller/, "").to_sym, :actions => klass.camelize.constantize.instance_variable_get(:@_checkable_routes))
|
8
16
|
end
|
9
17
|
permissions
|
10
18
|
end
|
11
19
|
|
12
20
|
# Stub methods
|
13
|
-
def is_action_permitted?
|
14
|
-
|
21
|
+
def is_action_permitted? permission
|
22
|
+
self.is_action_permitted_for_user? permission, current_user
|
15
23
|
end
|
16
24
|
|
17
|
-
def is_action_permitted_for_user?
|
18
|
-
|
25
|
+
def is_action_permitted_for_user? permission, user
|
26
|
+
# TODO: Avoid these code, maybe handle a callback included in application
|
27
|
+
!AccessRule.where(["permission = ? and user_id = ?", permission, user.id]).empty?
|
19
28
|
end
|
20
29
|
end
|
21
30
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 961916208
|
5
|
+
prerelease: 7
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
9
|
+
- 95
|
10
10
|
- pre
|
11
|
-
version: 0.1.
|
11
|
+
version: 0.1.95.pre
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Sergey Awanesov
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-07-
|
19
|
+
date: 2012-07-18 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
type: :development
|