lib/sitehub/collection/route_collection.rb in sitehub-0.4.2 vs lib/sitehub/collection/route_collection.rb in sitehub-0.4.3

- old
+ new

@@ -1,28 +1,26 @@ require_relative '../collection' class SiteHub class Collection < Hash class RouteCollection < Collection - - def add id, route, *opts + def add(id, route, *_opts) self[id] = route end def valid? - !self.empty? + !empty? end def resolve(env: nil) - return self.values.first unless self.values.find { |route| route.rule } - result = self.values.find { |route| route.applies?(env) } + return values.first unless values.find(&:rule) + result = values.find { |route| route.applies?(env) } result && result.resolve(env: env) end - def transform &block - each do |id, value| - self[id] = block.call(value) + def transform + each do |id, value| + self[id] = yield(value) end end - end end end