So basically, sometimes when I use JSON.parse and set the returned value to a variable, later in my app that variable will turn out to be NilClass.
What?
Take a look at this: Doing
require 'rest-client'
class Foo
attr_reader :response
@response = JSON.parse RestClient.get "http://path/to/api/?params"
end
foo = Foo.new
puts foo.response.class
prints out NilClass. Funky, right? On top of that, this means that all of the data within @response is rendered useless, as its inaccessible being of NilClass. Yet, just printing out foo.response will actually give all of data. Why is that? I made a workaround where within my method I set the Hash to a local variable and return that instead of a instance variable, but that's rather inconvenient.
@responseon any instance ofFoo, but on the classFooitself. What is your goal?