Sha256: fee7fa6a133af7ce751eb3ef8b9bf724125a929aece0c4175a8834aadd23917a
Contents?: true
Size: 568 Bytes
Versions: 10
Compression:
Stored size: 568 Bytes
Contents
require 'sitehub/location_rewriter' require 'sitehub/nil_location_rewriter' class SiteHub class LocationRewriters < Array DEFAULT = NilLocationRewriter.new include Equality def initialize(map = {}) enriched = map.collect do |pattern, path_template| matcher = pattern.is_a?(Regexp) ? pattern : /#{pattern}/ LocationRewriter.new(matcher, path_template) end super enriched end def find(url) result = super() do |directive| directive.match?(url) end result || DEFAULT end end end
Version data entries
10 entries across 10 versions & 1 rubygems