rollable 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,6 +30,22 @@ module Rollable
30
30
 
31
31
  private
32
32
 
33
+ # Not used
34
+ def set_role_checking_helpers
35
+ rollables = @rollables.reject { |c| c.nil? }
36
+ rollables.each do |object|
37
+ @role_names.each do |role|
38
+ ["_on","_of",""].each do |extra|
39
+ define_method("is_#{role}#{extra}?") do |thing|
40
+ self.roles.where("rollable_type = ? AND name = ?", object, role).inject(false) do |v,o| # You can't do an inner join on polymorphic relationships, unfortunately.
41
+ v ||= (o.rollable == thing)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
33
49
  def set_role_setter_helpers
34
50
  rollables = @rollables
35
51
  @role_names.each do |name|
@@ -96,7 +112,7 @@ module Rollable
96
112
 
97
113
  # TODO: Don't need method_missing no more, use dynamic dispatch instead.
98
114
  def method_missing(method, *args)
99
- if method =~ /^is_([a-z]+)(?:_(?:on|of))?\?$/ #Common spell to match against regex
115
+ if !(method =~ /is_a\?/) && method =~ /^is_([a-z]+)(?:_(?:on|of))?\?$/ #Common spell to match against regex
100
116
  role = $1
101
117
  that_thing = args.first.presence
102
118
  object = that_thing.class.to_s if that_thing
@@ -1,3 +1,3 @@
1
1
  module Rollable
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -33,4 +33,11 @@ describe User do
33
33
  @user.is_owner_of?(Horse.first).should be_true
34
34
  end
35
35
  end
36
+
37
+ context "Bugs" do
38
+ it "should still respond to is_a?" do
39
+ @user = User.create
40
+ @user.is_a?(User).should be_true
41
+ end
42
+ end
36
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-06-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2164273120 !ruby/object:Gem::Requirement
16
+ requirement: &2173010900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164273120
24
+ version_requirements: *2173010900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2164272620 !ruby/object:Gem::Requirement
27
+ requirement: &2173010400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.6'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2164272620
35
+ version_requirements: *2173010400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2164272160 !ruby/object:Gem::Requirement
38
+ requirement: &2173009940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2164272160
46
+ version_requirements: *2173009940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
- requirement: &2164271780 !ruby/object:Gem::Requirement
49
+ requirement: &2173009560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2164271780
57
+ version_requirements: *2173009560
58
58
  description: This gem adds agnostic roles for authorization to Rails.
59
59
  email:
60
60
  - mail@timonv.nl