rubymotion-community / sugarcube

Some sugar for your cocoa. RubyMotion helpers.
Other
422 stars 66 forks source link

Hash => Object not working #90

Closed holgersindbaek closed 11 years ago

holgersindbaek commented 11 years ago

I'm trying to convert a hash to an object, using to_object, but I keep getting a NoMethodError:

app_delegate.rb:37:in `application:didFinishLaunchingWithOptions:': undefined method `to_object' for {...}:Hash (NoMethodError)

Is the hash to object functionality still implemented?

I've required attributed string in rake file and bundles. I'm using the simple example from the README to test.

Am I doing anything wrong here?

holgersindbaek commented 11 years ago

Works perfectly if I'm including anonymous like this:

require 'sugarcube-anonymous'

Would probably be a good idea to correct the README. I would do it, but I don't know if it's the README or the code is a bit mixed up somehow.

I'm leaving this open for someone who knows better.

holgersindbaek commented 11 years ago

I'm working on a gem where I would like to use the to_object method, but I can't get it to work with the gem.

If I require sugarcube-anonymous in my "normal" app, it works fine, but it doesn't work in the gem.

Other Sugarcube methods works fine, but .to_object gives the error I got in the start.

Can anyone see a reason for this?

colinta commented 11 years ago

Ah, I think it's because you still need to require "sugarcube-anonymous" somewhere. If you're writing a rubymotion gem, you should have a file that adds your gem's files to app.files, right? In that file, add the require and see if that does the trick.

You're right, the README should mention sugarcube-anonymous. It's fixed in the 1.0 branch, which is getting merged soon.

holgersindbaek commented 11 years ago

Great... Things work if I, in the gem, require all the needed files in helu.rb (the place where i add app.files).

Thanks for the tip.