acts_as_authoritah 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/acts_as_authoritah.gemspec +2 -1
- data/lib/access_control.rb +30 -0
- data/lib/acts_as_authoritah.rb +2 -0
- metadata +4 -3
data/acts_as_authoritah.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_authoritah}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["BangTheTable","Unnikrishnan KP"]
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/loader.rb",
|
29
29
|
"lib/handler.rb",
|
30
30
|
"lib/access_rights.rb",
|
31
|
+
"lib/access_control.rb",
|
31
32
|
"lib/custom_exceptions.rb",
|
32
33
|
"test/acts_as_authoritah_test.rb",
|
33
34
|
"test/test_helper.rb"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Dir[File.join('lib','access_control','*.rb')].each {|f| require f}
|
2
|
+
|
3
|
+
module AccessControls
|
4
|
+
def self.access_control(controller)
|
5
|
+
params = controller.params
|
6
|
+
access_control_method = params[:action]
|
7
|
+
begin
|
8
|
+
access_module = (controller.class.to_s + "Access").constantize
|
9
|
+
rescue => e
|
10
|
+
if e.to_s =~ /uninitialized constant/
|
11
|
+
Rails.logger.info "\nAccess control module for #{controller.class.to_s} is not defined yet\n"
|
12
|
+
return true
|
13
|
+
else
|
14
|
+
raise
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
return access_module.send(access_control_method,controller)
|
20
|
+
rescue => e
|
21
|
+
if e.to_s =~ /undefined method/
|
22
|
+
Rails.logger.info "#{e.to_s}\nAccess control method '#{access_control_method}' is not defined yet in " +
|
23
|
+
controller.class.to_s + "Access" + "module\n"
|
24
|
+
return true
|
25
|
+
else
|
26
|
+
raise
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/acts_as_authoritah.rb
CHANGED
@@ -6,12 +6,14 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
6
6
|
require "loader"
|
7
7
|
require "handler"
|
8
8
|
require "access_rights"
|
9
|
+
require "access_control"
|
9
10
|
require "custom_exceptions"
|
10
11
|
|
11
12
|
$LOAD_PATH.shift
|
12
13
|
|
13
14
|
Spreadsheet.client_encoding = 'UTF-8'
|
14
15
|
|
16
|
+
|
15
17
|
if defined?(ActiveRecord::Base)
|
16
18
|
ActiveRecord::Base.extend ActsAsAuthoritah::Loader
|
17
19
|
ActiveRecord::Base.send :include, ActsAsAuthoritah::Handler
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_authoritah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- BangTheTable
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/loader.rb
|
55
55
|
- lib/handler.rb
|
56
56
|
- lib/access_rights.rb
|
57
|
+
- lib/access_control.rb
|
57
58
|
- lib/custom_exceptions.rb
|
58
59
|
- test/acts_as_authoritah_test.rb
|
59
60
|
- test/test_helper.rb
|