[MacRuby-devel] WebScripting protocol

Michael Jackson mjijackson at gmail.com
Mon Jun 7 16:21:16 PDT 2010


Hi,

I'm trying to create an object that conforms to the WebScripting
protocol, but the only method that is working is
invokeUndefinedMethodFromWebScript:withArguments:. Here's a sample of
my class so far. The puts statements are just there so I can see what
is actually being called.

For reference, the WebScripting protocol is defined here:
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/WebKit/Protocols/WebScripting_Protocol/Reference/Reference.html


class HelloScriptObject

  def self.isKeyExcludedFromWebScript(key)
    puts key.inspect
  end

  def self.webScriptNameForKey(key)
    puts key.inspect
  end

  def self.isSelectorExcludedFromWebScript(sel)
    puts sel.inspect
  end

  def self.webScriptNameForSelector(sel)
    puts sel.inspect
  end

  def invokeUndefinedMethodFromWebScript(name, withArguments:args)
    puts name
	puts args.inspect
  end

  def sayHi
    puts 'hi'
  end

end


The sayHi method is the one that I'm calling via JavaScript, but every
time it just defaults to using
invokeUndefinedMethodFromWebScript:withArguments: instead of using
self.isSelectorExcludedFromWebScript: to first check if the selector
is valid or not. Is support for this implemented yet (in 0.6)? If so,
what am I missing?

Thanks,

Michael

--
Michael Jackson
http://mjijackson.com
@mjijackson


More information about the MacRuby-devel mailing list