Sha256: 20718dfefbcc32473b3672a2ec777a933dc067a7193f5fdfb39d5b337a5e8af2

Contents?: true

Size: 470 Bytes

Versions: 1

Compression:

Stored size: 470 Bytes

Contents

require 'sitehub/path_directive'
class SiteHub
  class PathDirectives < Array
    def initialize(map = {})
      enriched = map.map do |array|
        matcher = array.first
        path_template = array.last

        matcher = matcher.is_a?(Regexp) ? matcher : /#{matcher}/
        PathDirective.new(matcher, path_template)
      end

      super enriched
    end

    def find(url)
      super() do |directive|
        directive.match?(url)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sitehub-0.4.3 lib/sitehub/path_directives.rb