Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Addressable::Template#match accepts optional block #132

Closed
wants to merge 1 commit into from

4 participants

@andreypopp

This mimics Regexp#match.

@coveralls

Coverage Status

Coverage increased (+0%) when pulling 5b9e6ea on andreypopp:master into 18f2305 on sporkmonger:master.

@levinalex

strike that, I can't read. match is not expand

@sporkmonger
Owner

This pull request needs tests before it can be accepted.

@andreypopp andreypopp closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 21, 2013
  1. @andreypopp
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/addressable/template.rb
View
14 lib/addressable/template.rb
@@ -390,7 +390,12 @@ def match(uri, processor=nil)
unparsed_values = uri.to_str.scan(expansion_regexp).flatten
if uri.to_str == pattern
- return Addressable::Template::MatchData.new(uri, self, mapping)
+ m = Addressable::Template::MatchData.new(uri, self, mapping)
+ if block_given?
+ yield m
+ else
+ return m
+ end
elsif expansions.size > 0
index = 0
expansions.each do |expansion|
@@ -443,7 +448,12 @@ def match(uri, processor=nil)
index = index + 1
end
end
- return Addressable::Template::MatchData.new(uri, self, mapping)
+ m = Addressable::Template::MatchData.new(uri, self, mapping)
+ if block_given?
+ yield m
+ else
+ return m
+ end
else
return nil
end
Something went wrong with that request. Please try again.