0
+%w(rubygems halcyon).each{|dep|require dep}
0
+ # The client interface for accessing services provided by the Halcyon
0
+ # application as defined in the controllers in <tt>app/</tt>.
0
+ # To use the Client in your application, create an instance and call methods
0
+ # defined here. For example:
0
+ # client = Weedb::Client.new('http://localhost:4647/')
0
+ # client.time #=> "Tue Apr 15 21:04:15 -0400 2008"
0
+ # You can just as easily call the primary <tt>get</tt>, <tt>post</tt>,
0
+ # <tt>put</tt>, and <tt>delete</tt> methods as well, passing in the +path+
0
+ # and any params. For example:
0
+ # client.get('/time') #=> "Tue Apr 15 21:04:15 -0400 2008"
0
+ # By default, if you enter a bad (non-existent) path or the application
0
+ # raises an exception and cannot complete successfully, the standard response
0
+ # format will be returned but with more appropriate +status+ and +body+
0
+ # values. For instance:
0
+ # client.get('/nonexistent/path') #=> {:status=>404,:body=>"Not Found"}
0
+ # Exceptions can be raised on any +status+ returned other than +200+ if you
0
+ # set <tt>Halcyon::Client#raise_exceptions!</tt> to +true+ (which is the
0
+ # client.raise_exceptions! #=> true
0
+ # client.get('/nonexistent/path') #=> NotFound exception is raised
0
+ # These exceptions all inherit from <tt>Halcyon::Exceptions::Base</tt> so
0
+ # <tt>rescue</tt>ing just normal Halcyon errors is trivial.
0
+ # However, setting this value can cause the meaning and the appropriate
0
+ # error-handling measures put in place in actions. Although each method
0
+ # could just as easily set the +raise_exceptions+ configuration option
0
+ # itself, it is not advised to do so due to the possibility of non-
0
+ # consistent and confusing behavior it can cause.
0
+ # If raising exceptions is preferred, it should be set as soon as the
0
+ # client is created and the client methods should be designed accordingly.
0
+ class Client < Halcyon::Client
0
+ # Send data to the WeeDB
0
+ # +data+ the data to save
0
+ # client.push({'foo'=>'bar'}) #=> '1aB2'
0
+ # Returns String:record_id
0
+ if (response = post('/records', :data => data.to_json))[:status] == 200
0
+ # failure; return all response data for individual attention
0
+ alias_method :store, :push
0
+ # Alias for <tt>push</tt>.
0
+ # client << {'key' => 'value'} #=> '2bC3'
0
+ # Retrieve the data from the WeeDB
0
+ # +key+ the ID the data is saved under
0
+ # client.retrieve('1aB2') #=> {'foo'=>'bar'}
0
+ if (response = get("/records/#{key}"))[:status] == 200
0
+ # failure; return all response data for individual attention
0
+ alias_method :retrieve, :pull
0
+ # Alias for <tt>pull</tt>.
0
+ # client['2bC3'] #=> {'key' => 'value'}
Comments
No one has commented yet.