bravo_guard 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,9 +45,10 @@ module BravoGuard::Model::ObjectMethods
45
45
  # nodoc
46
46
  def allows?(actor, *permissions)
47
47
  begin
48
- permission = permissions.join('_')
49
- method_name = [:allows, permission_name(permission)].join('_') + '?'
48
+ permission = permission_name(permissions.join('_'))
49
+ method_name = [:allows, permission].join('_') + '?'
50
50
  self.actor = actor
51
+ check_anon_permissions!(permission)
51
52
  send method_name
52
53
  rescue BravoGuard::PermissionDenied
53
54
  return false
@@ -60,6 +61,19 @@ module BravoGuard::Model::ObjectMethods
60
61
 
61
62
 
62
63
 
64
+ # nodoc
65
+ def anon_permissions
66
+ []
67
+ end
68
+
69
+
70
+ # auto-reject anons
71
+ def check_anon_permissions!(permission)
72
+ return unless actor.nil?
73
+ no! unless anon_permissions.include?(permission)
74
+ end
75
+
76
+
63
77
  # shorthand for 'return false'. allows?() will catch this and return false
64
78
  def no!
65
79
  raise BravoGuard::PermissionDenied
@@ -1,3 +1,3 @@
1
1
  module BravoGuard
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
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.3
4
+ version: 0.0.4
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-30 00:00:00.000000000 Z
12
+ date: 2012-02-01 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: 54149005
73
+ hash: -121529389
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: 54149005
82
+ hash: -121529389
83
83
  requirements: []
84
84
  rubyforge_project:
85
85
  rubygems_version: 1.8.10