Sha256: b77177001e48835ca462471450b95d48fc23d349eb466292263b9bf5c9bb3c60
Contents?: true
Size: 545 Bytes
Versions: 6
Compression:
Stored size: 545 Bytes
Contents
require_relative '../collection' class SiteHub class Collection < Hash class RouteCollection < Collection def add(id, route, *_opts) self[id] = route end def valid? !empty? end def resolve(env: nil) return values.first unless values.find(&:rule) result = values.find { |route| route.applies?(env) } result && result.resolve(env: env) end def transform each do |id, value| self[id] = yield(value) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems