mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
merges r20242 from trunk into ruby_1_9_1. recovers 1.8-compatible
parsing for OptionParser. * lib/optparse.rb (OptionParser::make_switch): makes default conversion to splat. [ruby-list:45645] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7e5c0ea087
commit
b0722f6063
2 changed files with 11 additions and 1 deletions
|
@ -996,6 +996,7 @@ class OptionParser
|
|||
end
|
||||
private :notwice
|
||||
|
||||
SPLAT_PROC = proc {|*a| a}
|
||||
#
|
||||
# Creates an OptionParser::Switch from the parameters. The parsed argument
|
||||
# value is passed to the given block, where it can be processed.
|
||||
|
@ -1076,7 +1077,11 @@ class OptionParser
|
|||
# directly specified pattern(any object possible to match)
|
||||
if (!(String === o || Symbol === o)) and o.respond_to?(:match)
|
||||
pattern = notwice(o, pattern, 'pattern')
|
||||
conv = pattern.method(:convert).to_proc if pattern.respond_to?(:convert)
|
||||
if pattern.respond_to?(:convert)
|
||||
conv = pattern.method(:convert).to_proc
|
||||
else
|
||||
conv = SPLAT_PROC
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue