authorization-san 2.1.1 → 2.2.0

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- (c) 2011 Fingertips, Manfred Stienstra <m.stienstra@fngtps.com>
1
+ (c) 2012 Fingertips, Manfred Stienstra <m.stienstra@fngtps.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to
@@ -19,3 +19,11 @@ Authorization-san allows you to specify access policies in your controllers. The
19
19
  end
20
20
 
21
21
  The best place to start learning more is the <tt>examples</tt> directory in the source.
22
+
23
+ == Contributers
24
+
25
+ In order of appearance:
26
+
27
+ * Manfred Stienstra <manfred@fngtps.com>
28
+ * Eloy Duran <eloy@fngtps.com>
29
+ * Hrvoje Šimić <shime.ferovac@gmail.com>
@@ -2,10 +2,14 @@ module Authorization
2
2
  module BlockAccess
3
3
  protected
4
4
 
5
- def die_if_undefined #:nodoc:
6
- if !self.respond_to?(:access_allowed_for) or access_allowed_for.nil?
7
- raise ArgumentError, "Please specify access control using `allow_access' in the controller"
8
- end
5
+ def _raise_undefined_error
6
+ raise ArgumentError, "Please specify access control using `allow_access' in the controller"
7
+ end
8
+
9
+ def _die_if_undefined #:nodoc:
10
+ _raise_undefined_error if access_allowed_for.nil?
11
+ rescue NoMethodError
12
+ _raise_undefined_error
9
13
  end
10
14
 
11
15
  # Block access to all actions in the controller, designed to be used as a <tt>before_filter</tt>.
@@ -21,7 +25,7 @@ module Authorization
21
25
  # The +block_access+ method returns +true+ when access was granted. It returns
22
26
  # the same thing as +access_forbidden+ when access was forbidden.
23
27
  def block_access
24
- die_if_undefined
28
+ _die_if_undefined
25
29
  unless @authenticated.nil?
26
30
  if @authenticated.respond_to?(:role)
27
31
  checked = @authenticated.role.to_s
@@ -82,7 +86,7 @@ module Authorization
82
86
  end
83
87
 
84
88
  def _access_allowed?(params, role, authenticated=nil) #:nodoc:
85
- die_if_undefined
89
+ _die_if_undefined
86
90
  if rules = access_allowed_for[role]
87
91
  rules.each do |rule|
88
92
  if _access_allowed_with_rule?(rule, params, role, authenticated)
@@ -7,7 +7,7 @@ module Authorization
7
7
  # action_allowed?({:action => :show, :id => 1}, :editor)
8
8
  def action_allowed?(params, role=:all)
9
9
  ::ActiveSupport::Deprecation.warn("action_allowed? has been deprecated.", caller)
10
- die_if_undefined
10
+ _die_if_undefined
11
11
  return false if (rules = access_allowed_for[role]).nil?
12
12
  !rules.detect { |rule| action_allowed_by_rule?(rule, params, role) }.nil?
13
13
  end
@@ -30,7 +30,7 @@ module Authorization
30
30
  def resource_allowed?(params, role=:all, user=nil)
31
31
  ::ActiveSupport::Deprecation.warn("resource_allowed? has been deprecated.", caller)
32
32
  user ||= @authenticated
33
- die_if_undefined
33
+ _die_if_undefined
34
34
  return false if (rules = access_allowed_for[role]).nil?
35
35
  !rules.detect { |rule| resource_allowed_by_rule?(rule, params, role, user) }.nil?
36
36
  end
@@ -70,7 +70,7 @@ module Authorization
70
70
  # block_allowed?(:guest)
71
71
  def block_allowed?(role)
72
72
  ::ActiveSupport::Deprecation.warn("block_allowed? has been deprecated.", caller)
73
- die_if_undefined
73
+ _die_if_undefined
74
74
  return false if (rules = access_allowed_for[role]).nil?
75
75
  !rules.detect { |rule| block_allowed_by_rule?(rule) }.nil?
76
76
  end
metadata CHANGED
@@ -1,33 +1,24 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: authorization-san
3
- version: !ruby/object:Gem::Version
4
- hash: 9
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.0
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 1
9
- - 1
10
- version: 2.1.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Manfred Stienstra
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-22 00:00:00 Z
12
+ date: 2012-06-22 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: A plugin for authorization in a ReSTful application.
22
15
  email: manfred@fngtps.com
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
- extra_rdoc_files:
18
+ extra_rdoc_files:
28
19
  - LICENSE
29
20
  - README.rdoc
30
- files:
21
+ files:
31
22
  - LICENSE
32
23
  - README.rdoc
33
24
  - lib/authorization.rb
@@ -37,36 +28,26 @@ files:
37
28
  - rails/init.rb
38
29
  homepage: http://fingertips.github.com
39
30
  licenses: []
40
-
41
31
  post_install_message:
42
32
  rdoc_options: []
43
-
44
- require_paths:
33
+ require_paths:
45
34
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
35
+ required_ruby_version: !ruby/object:Gem::Requirement
47
36
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- hash: 3
52
- segments:
53
- - 0
54
- version: "0"
55
- required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
42
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
64
47
  requirements: []
65
-
66
48
  rubyforge_project:
67
- rubygems_version: 1.8.18
49
+ rubygems_version: 1.8.23
68
50
  signing_key:
69
51
  specification_version: 3
70
52
  summary: A plugin for authorization in a ReSTful application.
71
53
  test_files: []
72
-