Class: SiteHub::LocationRewriters
- Inherits:
-
Array
- Object
- Array
- SiteHub::LocationRewriters
- Defined in:
- lib/sitehub/location_rewriters.rb
Constant Summary collapse
- DEFAULT =
NilLocationRewriter.new
Instance Method Summary collapse
- #find(url) ⇒ Object
-
#initialize(map = {}) ⇒ LocationRewriters
constructor
A new instance of LocationRewriters.
Constructor Details
#initialize(map = {}) ⇒ LocationRewriters
Returns a new instance of LocationRewriters.
7 8 9 10 11 12 13 14 |
# File 'lib/sitehub/location_rewriters.rb', line 7 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 |
Instance Method Details
#find(url) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/sitehub/location_rewriters.rb', line 16 def find(url) result = super() do |directive| directive.match?(url) end result || DEFAULT end |