Sha256: 9396d6dbb28f1f989d26a6edf6228172b1a2c4181fa7a18ea3cd983bad35429f
Contents?: true
Size: 701 Bytes
Versions: 2
Compression:
Stored size: 701 Bytes
Contents
class SiteHub class PathDirective attr_reader :matcher, :path_template def initialize matcher, path_template @matcher, @path_template = matcher, path_template end def match? url !!matcher.match(url) end def path_template @path_template.dup end def apply url url_components = matcher.match(url).captures path_template.tap do |p| url_components.each_with_index do |m, index| p.gsub!(RequestMapping::CAPTURE_GROUP_REFERENCE % (index+1), m) end end end def == other other.is_a?(PathDirective) && self.matcher == other.matcher && self.path_template == other.path_template end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sitehub-0.4.2 | lib/sitehub/path_directive.rb |
sitehub-0.4.1 | lib/sitehub/path_directive.rb |