Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

call bang and predicate methods

  • Loading branch information...
commit 48abdbbcfb9589fafe1366c4b265995b2ed61288 1 parent e3920d8
@defunkt authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 lib/lyndon/ruby.rb
View
14 lib/lyndon/ruby.rb
@@ -5,13 +5,23 @@ class Ruby
#
# Ruby.IO_read(file)
# Ruby.puts('hi')
+ # Ruby.require('uri')
def invokeUndefinedMethodFromWebScript(name, withArguments:args)
if respond_to? name
send(name, *args)
elsif Kernel.respond_to? name
Kernel.send(name, *args)
- elsif name =~ /^([A-Z][A-Za-z])_(\w+)/
- Kernel.const_get($1).send($2, *args)
+ elsif name =~ /^([A-Z][A-Za-z]+)_(.+)/
+ const = Kernel.const_get($1)
+ method = $2
+
+ if const.respond_to? method
+ const.send(method, *args)
+ elsif const.respond_to?("#{method}?")
+ const.send("#{method}?", *args)
+ elsif const.respond_to?("#{method}!")
+ const.send("#{method}!", *args)
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.