Permalink
Browse files

use case / when rather than calling to_s multiple times

  • Loading branch information...
1 parent 1aacb77 commit 8eee042e27d1a12793b55ccedbef3f407ebe7e12 @tenderlove committed Dec 28, 2010
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/to_lang/string_methods.rb
@@ -47,13 +47,14 @@ def method_missing(method, *args, &block)
# @private
#
def respond_to?(method, include_private = false)
- if method.to_s =~ /^to_(.*)_from_(.*)$/ && CODEMAP[$1] && CODEMAP[$2]
- true
- elsif method.to_s =~ /^to_(.*)$/ && CODEMAP[$1]
- true
- else
- super
+ case method.to_s
+ when /^to_(.*)_from_(.*)$/
+ return true if CODEMAP[$1] && CODEMAP[$2]
+ when /^to_(.*)$/
+ return true if CODEMAP[$1]
end
+
+ super
end
end
end

0 comments on commit 8eee042

Please sign in to comment.