rubymotion/teacup — pull request #55 by fcheung (2012-12-16 12:13:41+00:00)
Title: Fix dependency issue with z_handlers.rb / handler.rb

I've been getting problems with recent versions of teacup (de36e232 was ok, master is not) with the following error:

Terminating app due to uncaught exception 'NoMethodError', reason: 'undefined method `handler' for Teacup:Class (NoMethodError)

It looks like this is because z_core_extensions/z_handlers.rb was being loaded before handler.rb, even though z_handlers.rb needs handler.rb to be already loaded (since it calls `Teacup.handler`)

My best guess as to why this happens is because z_handlers.rb reopens the Teacup module to define the calculate method. I think that because rubymotion sees lots of files that define/reopen the Teacup module it doesn't know which one comes first and, by luck or otherwise is choosing z_handlers.rb as the file that defines the Teacup module and so loads it early on.

This patch dodges the issue by moving the definition of the calculate method into its own file, so that Rubymotion doesn't feel the need to load z_handlers.rb early.

I don't know whether this is something rubymotion could be detecting, but until then it fixes the issue for me