cancan-permits 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cancan-permits}
8
- s.version = "0.3.8"
8
+ s.version = "0.3.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
@@ -74,11 +74,11 @@ module Permit
74
74
  end
75
75
 
76
76
  def can(action, subject, conditions = nil, &block)
77
- can_definitions << rule_class.new(true, action, subject, conditions, block)
77
+ rules << rule_class.new(true, action, subject, conditions, block)
78
78
  end
79
79
 
80
80
  def cannot(action, subject, conditions = nil, &block)
81
- can_definitions << rule_class.new(false, action, subject, conditions, block)
81
+ rules << rule_class.new(false, action, subject, conditions, block)
82
82
  end
83
83
 
84
84
  def owns(user, clazz, ownership_relation = :user_id, user_id_attribute = :id, strategy_used = nil)
@@ -122,8 +122,19 @@ module Permit
122
122
  user.has_role? permit_name(self.class)
123
123
  end
124
124
 
125
- def can_definitions
126
- ability.send :can_definitions
125
+ def rules
126
+ return rules_1_5 if rules_1_5
127
+ return rules_1_4 if rules_1_4
128
+ raise "CanCan ability.rules could not be found. Possibly due to CanCan API change since 1.5"
127
129
  end
130
+
131
+ def rules_1_5
132
+ ability.send :rules
133
+ end
134
+
135
+ def rules_1_4
136
+ ability.send :can_definitions
137
+ end
138
+
128
139
  end
129
140
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 8
9
- version: 0.3.8
8
+ - 9
9
+ version: 0.3.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup