Skip to content

Commit

Permalink
call bang and predicate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Jun 24, 2009
1 parent e3920d8 commit 48abdbb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/lyndon/ruby.rb
Expand Up @@ -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
Expand Down

0 comments on commit 48abdbb

Please sign in to comment.