Sha256: 771415f1977d64eac194e07ceab2ba8d2340e831f707d5ad80775675834d15ae

Contents?: true

Size: 459 Bytes

Versions: 2

Compression:

Stored size: 459 Bytes

Contents

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

        matcher = matcher.is_a?(Regexp) ? matcher : %r{#{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

2 entries across 2 versions & 1 rubygems

Version Path
sitehub-0.4.2 lib/sitehub/path_directives.rb
sitehub-0.4.1 lib/sitehub/path_directives.rb