Sha256: 5788d57599f423ba34dd431ef49c33e2a59e63bfed4fa57e74369002a1238259

Contents?: true

Size: 519 Bytes

Versions: 10

Compression:

Stored size: 519 Bytes

Contents

module Restfulie::Client::Feature::OpenSearch
  
  class PatternMatcher

    def match(params, pattern)
      params = params.collect do |key, value|
        [key, value]
      end
      pattern = params.inject(pattern) do |pattern, p|
        what = "{#{p[0]}}"
        if pattern[what]
          pattern[what]= "#{p[1]}"
        end
        what = "{#{p[0]}?}"
        if pattern[what]
          pattern[what]= "#{p[1]}"
        end
        pattern
      end
      pattern.gsub(/\{[^\?]*\?\}/,"")
    end

  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
restfulie-nosqlite-1.0.4 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-1.1.1 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-1.1.0 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-nosqlite-1.0.3 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-1.0.3 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-1.0.0 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-1.0.0.beta5 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-1.0.0.beta4 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-1.0.0.beta1 lib/restfulie/client/feature/open_search/pattern_matcher.rb
restfulie-0.1.0.beta1 lib/restfulie/client/feature/open_search/pattern_matcher.rb