Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rm *_all?

  • Loading branch information...
commit ecf7143f8e82daaff4efeabbc6b7b91524d8d233 1 parent ed8b691
@matthewvermaak authored
View
18 README.rdoc
@@ -134,11 +134,6 @@ Each of the following methods are injected at the instance and class level.
the boolean form of has, returns true/false.
-* <tt>has_all?(*roles)</tt>
-
- You can end a "sentence" with this method, allowing you to ask for ALL roles to be present. This is a more expensive operation, conducting a search on each role supplied as an argument.
- The nature of the _all methods prevents further chaining.
-
* <tt>over(*permissionables)</tt>
provide any number of permissionable instances or Klasses. This is interpretted as asking for principals having permissions over any of these permissionables. Returns the principal
@@ -148,11 +143,6 @@ Each of the following methods are injected at the instance and class level.
The boolean form of over, returns true/false.
-* <tt>over_all?(*permissionables)</tt>
-
- You can end a "sentence" with this method, allowing you to ask for a principal who has permission over ALL of these permisisonables. Again, this is subject to the _all
- exception, in that this method prevents further chaining.
-
* <tt>grant(role_name, permissionable = nil)</tt>
Assign a role to a principal over an optional permissionable. Validated against the current Sanction::Role::Definition .
@@ -179,10 +169,6 @@ Each of the following methods are injected at the instance and class level. (Exc
The boolean form of with(*roles), returns true/false.
-* <tt>with_all?(*roles)</tt>
-
- The _all version of with(*roles).
-
* <tt>for(*principals)</tt>
Provide any number of principals, for which you are searching for having a role/permission over the root permissionable.
@@ -191,10 +177,6 @@ Each of the following methods are injected at the instance and class level. (Exc
The boolean form for for(*principals), returns true/false.
-* <tt>for_all?(*principals)</tt>
-
- The _all version of for(*principals).
-
* <tt>authorize(role_name, principal)</tt>
Must provide a role name and principal.
View
3  changelog
@@ -1,5 +1,6 @@
1.2.0
* Brings preloading of roles as an option. Person.find(:all, :preload_roles => true)
-* Uniformly treats class parameters across API, including *_all? methods.
+* Uniformly treats class parameters across API
* Collection methods to Sanction::Role::Definition
* Add warnings in configuration
+* Removes _all? methods
View
8 lib/sanction/permissionable/for.rb
@@ -35,10 +35,6 @@ def for(*args)
def for?(*args)
!self.for(*args).blank?
end
-
- def for_all?(*args)
- !args.map {|a| self.for(a)}.inject(&:&).blank?
- end
end
module InstanceMethods
@@ -69,10 +65,6 @@ def for(*args)
def for?(*args)
!self.for(*args).blank?
end
-
- def for_all?(*args)
- !args.map {|a| self.for(a)}.inject(&:&).blank?
- end
end
end
end
View
17 lib/sanction/permissionable/with.rb
@@ -26,19 +26,6 @@ def with(*role_names)
def with?(*role_names)
!with(*role_names).blank?
end
-
- def with_all?(*role_names)
- result = nil
- role_names.each do |role|
- if result.nil?
- result = self.with(role)
- else
- result = result & self.with(role)
- end
- end
-
- !result.blank?
- end
end
module InstanceMethods
@@ -65,10 +52,6 @@ def with(*role_names)
def with?(*role_names)
!with(*role_names).blank?
end
-
- def with_all?(*role_names)
- !role_names.map {|r| with(r)}.inject(&:&).blank?
- end
end
end
end
View
17 lib/sanction/principal/has.rb
@@ -27,19 +27,6 @@ def has(*role_names)
def has?(*role_names)
!has(*role_names).blank?
end
-
- def has_all?(*role_names)
- result = nil
- role_names.each do |role|
- if(result.nil?)
- result = self.has(role)
- else
- result = result & has(role)
- end
- end
-
- !result.blank?
- end
end
module InstanceMethods
@@ -66,10 +53,6 @@ def has(*role_names)
def has?(*role_names)
!has(*role_names).blank?
end
-
- def has_all?(*role_names)
- !role_names.map {|r| has(r)}.inject(&:&).blank?
- end
end
end
end
View
8 lib/sanction/principal/over.rb
@@ -34,10 +34,6 @@ def over(*args)
def over?(*args)
!over(*args).blank?
end
-
- def over_all?(*args)
- !args.map {|a| over(a)}.inject(&:&).blank?
- end
end
module ClassMethods
@@ -69,10 +65,6 @@ def over(*args)
def over?(*args)
!over(*args).blank?
end
-
- def over_all?(*args)
- !args.map {|a| over(a)}.inject(&:&).blank?
- end
end
end
end
View
4 lib/sanction/result/blank_array.rb
@@ -15,13 +15,13 @@ def method_missing(m, *args)
if @decoy.class.respond_to? :is_a_principal? and @decoy.class.is_a_principal?
if [:has, :over].include? m
Sanction::Result::BlankArray.construct(@decoy)
- elsif [:has?, :has_all?, :over?, :over_all?].include? m
+ elsif [:has?, :over?].include? m
false
end
elsif @decoy.class.respond_to? :is_a_permissionable? and @decoy.class.is_a_permissionable?
if [:with, :for].include? m
Sanction::Result::BlankArray.construct(@decoy)
- elsif [:with?, :with_all?, :for?, :for_all?].include? m
+ elsif [:with?, :for?].include? m
false
end
else
View
60 test/unit/sanction_test.rb
@@ -277,10 +277,6 @@ def test_multiple_roles
assert Person.has?(:editor)
assert Person.has?(:writer)
- assert Person.has_all?(:editor, :writer)
- assert Person.over(Magazine).has_all?(:editor, :writer)
- assert Person.over(Magazine.first).has_all?(:editor, :writer)
-
assert Person.has(:editor).over?(Magazine)
assert Person.has(:writer).over?(Magazine)
@@ -302,8 +298,6 @@ def test_role_over_multiple_permissionables
assert Person.first.grant(:editor, Magazine.last)
assert Sanction::Role.count(:all) == 2
- assert Person.has(:editor).over_all?(Magazine.first, Magazine.last)
- assert Person.first.has(:editor).over_all?(Magazine.first, Magazine.last)
assert Person.first.revoke(:editor, Magazine.first)
assert Person.first.revoke(:editor, Magazine.last)
@@ -590,58 +584,4 @@ def test_iteration_of_preloaded_roles
assert !Person.first.has?(:reader)
end
-
- def test_has_all_with_preloaded_roles
- Person.grant(:reader, Magazine)
- Person.grant(:editor, Magazine)
-
- person = Person.first :preload_roles => true
-
- Person.revoke(:reader, Magazine)
- Person.revoke(:editor, Magazine)
-
- assert person.has_all?(:reader, :editor)
- assert !Person.first.has_all?(:reader, :editor)
- assert !person.has_all?(:reader, :editor, :owner)
- end
-
- def test_with_all_with_preloaded_roles
- Person.grant(:reader, Magazine)
- Person.grant(:editor, Magazine)
-
- magazine = Magazine.first :preload_roles => true
-
- Person.revoke(:reader, Magazine)
- Person.revoke(:editor, Magazine)
-
- assert magazine.with_all?(:reader, :editor)
- assert !Magazine.first.with_all?(:reader, :editor)
- assert !magazine.with_all?(:reader, :editor, :owner)
- end
-
- def test_over_all_with_prelaoded_roles
- Person.grant(:reader, Magazine)
-
- person = Person.first :preload_roles => true
-
- assert Person.first.over_all?(Magazine.first, Magazine.last)
-
- Person.revoke(:reader, Magazine)
-
- assert person.over_all?(Magazine.first, Magazine.last)
- assert !Person.first.over_all?(Magazine.first, Magazine.last)
- end
-
- def test_for_all_with_preloaded_roles
- Person.grant(:reader, Magazine)
-
- magazine = Magazine.first :preload_roles => true
-
- assert Magazine.first.for_all?(Person.first, Person.last)
-
- Person.revoke(:reader, Magazine)
-
- assert magazine.for_all?(Person.first, Person.last)
- assert !Magazine.first.for_all?(Person.first, Person.last)
- end
end
Please sign in to comment.
Something went wrong with that request. Please try again.