Open mwunsch opened 11 years ago
Just ran into a problem where autoload
doesn't seem to work properly:
class MyApp::Thing
class << self
def client
MyApp::Client.new
end
def list(options = {})
response = client.list_things(options).perform
response.parse['results'].map do |attrs|
self.new attrs
end
end
end
def initialize(attrs)
@attrs = attrs
end
end
> MyApp::Thing.list
cannot load such file -- multi_json
/Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/weary-1.1.3/lib/weary/response.rb:59:in `parse'
/Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/promise-0.3.0/lib/promise.rb:89:in `method_missing'
/Users/manuel/code/myapp/lib/my_app/thing.rb:9:in `list'
Adding require 'multi_json'
to the top of MyApp::Thing
makes the error disappear.
I need to
autoload
, particularly where thread-safety is concerned.autoload
torequire
, specifically for loading "multi_json", even thought we might not always parse json.