cancan-permits 0.3.8 → 0.3.9
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/VERSION +1 -1
- data/cancan-permits.gemspec +1 -1
- data/lib/cancan-permits/permit/base_permit.rb +15 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.9
|
data/cancan-permits.gemspec
CHANGED
@@ -74,11 +74,11 @@ module Permit
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def can(action, subject, conditions = nil, &block)
|
77
|
-
|
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
|
-
|
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
|
126
|
-
|
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
|