lib/rails/auth/acl.rb in rails-auth-0.4.0 vs lib/rails/auth/acl.rb in rails-auth-0.4.1

- old
+ new

@@ -20,12 +20,16 @@ # @param [Array<Hash>] :acl Access Control List configuration # @param [Hash] :matchers predicate matchers for use with this ACL # def initialize(acl, matchers: {}) + raise TypeError, "expected Array for acl, got #{acl.class}" unless acl.is_a?(Array) + @resources = [] - acl.each_with_index do |entry| + acl.each do |entry| + raise TypeError, "expected Hash for acl entry, got #{entry.class}" unless entry.is_a?(Hash) + resources = entry["resources"] raise ParseError, "no 'resources' key present in entry: #{entry.inspect}" unless resources predicates = parse_predicates(entry, matchers.merge(DEFAULT_MATCHERS))