lib/certmeister/policy/chain_all.rb in certmeister-0.3.2 vs lib/certmeister/policy/chain_all.rb in certmeister-0.4.0
- old
+ new
@@ -4,29 +4,20 @@
module Policy
class ChainAll
- def initialize(policys)
- validate_policys(policys)
- @policys = policys
+ def initialize(policies)
+ Certmeister::Policy.validate_policies(policies)
+ @policies = policies
end
def authenticate(request)
success = Certmeister::Policy::Response.new(true, nil)
- @policys.inject(success) do |continue, policy|
+ @policies.inject(success) do |continue, policy|
response = policy.authenticate(request)
break response unless response.authenticated?
continue
- end
- end
-
- private
-
- def validate_policys(policys)
- unless policys.is_a?(Enumerable) and policys.respond_to?(:size) and policys.size > 0 and
- policys.all? { |policy| Certmeister::Policy.validate_authenticate_signature(policy) }
- raise ArgumentError.new("enumerable collection of policys required")
end
end
end