bravo_guard 0.0.2 → 0.0.3

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.
@@ -5,6 +5,7 @@ module BravoGuard
5
5
 
6
6
  included do
7
7
  attr_accessor :actor
8
+ include ObjectMethods
8
9
  end
9
10
 
10
11
 
@@ -36,18 +37,17 @@ end
36
37
 
37
38
 
38
39
 
39
- # nodoc
40
- module BravoGuard::Model::InstanceMethods
40
+ # ObjectMethods to avoid deprecation warnings on InstanceMethods
41
+ module BravoGuard::Model::ObjectMethods
41
42
 
42
43
 
43
44
 
44
45
  # nodoc
45
46
  def allows?(actor, *permissions)
46
47
  begin
48
+ permission = permissions.join('_')
49
+ method_name = [:allows, permission_name(permission)].join('_') + '?'
47
50
  self.actor = actor
48
- permission = permission_name(permissions.join('_'))
49
- method_name = [:allows, permission].join('_') + '?'
50
- check_anon_permission! permission
51
51
  send method_name
52
52
  rescue BravoGuard::PermissionDenied
53
53
  return false
@@ -60,22 +60,6 @@ module BravoGuard::Model::InstanceMethods
60
60
 
61
61
 
62
62
 
63
- # anything in here will not be auto-rejected for anons, instead, the permission
64
- # method will be called as usual so you can still check object state etc
65
- def anon_permissions
66
- []
67
- end
68
-
69
-
70
- # nodoc
71
- def check_anon_permission!(permission)
72
- is_anon = actor.nil? || (actor.respond_to?(:anon) && actor.anon?)
73
- return if anon_permissions.include?(permission.intern)
74
- return unless is_anon
75
- no!
76
- end
77
-
78
-
79
63
  # shorthand for 'return false'. allows?() will catch this and return false
80
64
  def no!
81
65
  raise BravoGuard::PermissionDenied
@@ -1,3 +1,3 @@
1
1
  module BravoGuard
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bravo_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-27 00:00:00.000000000 Z
12
+ date: 2012-01-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -70,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  segments:
72
72
  - 0
73
- hash: 920269711
73
+ hash: 54149005
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  segments:
81
81
  - 0
82
- hash: 920269711
82
+ hash: 54149005
83
83
  requirements: []
84
84
  rubyforge_project:
85
85
  rubygems_version: 1.8.10