Class: BigDoor::ResourceWithAssociation
- Defined in:
- lib/big_door/resource_with_association.rb
Overview
This module provides Resource class with Association
Direct Known Subclasses
Instance Method Summary collapse
-
#associate_with(resource, client, payload = {}) ⇒ Object
Assocaiate this Resource with another Resource.
Methods inherited from Resource
all, #delete, #end_point, end_point, end_point_from_classname, #get_id, #initialize, #instance_to_payload, #load, #response_to_instance, #save
Constructor Details
This class inherits a constructor from BigDoor::Resource
Instance Method Details
#associate_with(resource, client, payload = {}) ⇒ Object
Assocaiate this Resource with another Resource
@param [BigDoor::Resource] resource
Resource to be associated with. See BigDoor documentation for list
of objects which allow association
@param [BigDoor::Client] client
Initialized BigDoor::Client object
@param [Hash] payload
Hash to be converted to HTTP POST form-url-encoded body
@return [Hash] Decoded JSON response if any
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/big_door/resource_with_association.rb', line 23 def associate_with(resource, client, payload = {}) $log.debug('associate_with'); uri = sprintf '%s/%s/%s/%s', end_point, self.resource_id, resource.resource_name, resource.resource_id $log.debug( sprintf 'uri = %s', uri ) result = client.post( uri , { 'format' => 'json'}, payload ) $log.debug(sprintf 'result = %s', result.inspect ); result end |