susestudio/studio_api — pull request #6 by vmoravec (2012-06-05 13:55:21+00:00)
Title: Inspect connection before resource call

Now if no connection is defined we get:
```ruby
StudioApi::Appliance.find 12345
NoMethodError: undefined method `path' for nil:NilClass
from /home/vmoravec/.rvm/gems/ruby-1.8.7-p352/gems/activeresource-3.2.1/lib/active_resource/base.rb:588:in `prefix'
from /home/vmoravec/.rvm/gems/ruby-1.8.7-p352/gems/studio_api-3.2.0/lib/studio_api/studio_resource.rb:73:in `collection_path'
from /home/vmoravec/.rvm/gems/ruby-1.8.7-p352/gems/activeresource-3.2.1/lib/active_resource/base.rb:901:in `find_every'
from /home/vmoravec/.rvm/gems/ruby-1.8.7-p352/gems/activeresource-3.2.1/lib/active_resource/base.rb:814:in `find'
from (irb):4
```
With this patch:
```ruby
StudioApi::Appliance.find 12345
RuntimeError: Connection to Studio is not set
Try: StudioApi::Util.studio_connection = StudioApi::Connection.new username, api_key, api_uri
from ./studio_api/studio_resource.rb:82:in `inspect_connection'
from ./studio_api/studio_resource.rb:73:in `collection_path'
from /home/vmoravec/.rvm/gems/ruby-1.8.7-p352/gems/activeresource-3.2.1/lib/active_resource/base.rb:901:in `find_every'
from /home/vmoravec/.rvm/gems/ruby-1.8.7-p352/gems/activeresource-3.2.1/lib/active_resource/base.rb:814:in `find'
from (irb):2
```

Tests included.