class Hoodoo::Services::Middleware::InterResourceRemote
This is an endpoint which the middleware uses for inter-resource calls over another ‘wrapped’ endpoint. This endpoint manages all the inter-resource preparation and post processing, but calls in to another wrapped endpoint to actually talk to the resource for which the inter-resource call is being made.
Since it wraps another endpoint, instantiation requirements are rather unusual - see configure_with
for details.
Public Instance Methods
See Hoodoo::Client::Endpoint#create
.
# File lib/hoodoo/services/middleware/endpoints/inter_resource_remote.rb, line 87 def create( body_hash, query_hash = nil ) result = preprocess( :create ) result = @wrapped_endpoint.create( body_hash, query_hash ) if result.nil? return postprocess( result ) end
See Hoodoo::Client::Endpoint#delete
.
# File lib/hoodoo/services/middleware/endpoints/inter_resource_remote.rb, line 103 def delete( ident, query_hash = nil ) result = preprocess( :delete ) result = @wrapped_endpoint.delete( ident, query_hash ) if result.nil? return postprocess( result ) end
See Hoodoo::Client::Endpoint#list
.
# File lib/hoodoo/services/middleware/endpoints/inter_resource_remote.rb, line 71 def list( query_hash = nil ) result = preprocess( :list ) result = @wrapped_endpoint.list( query_hash ) if result.nil? return inject_enumeration_state( postprocess( result ), query_hash ) end
See Hoodoo::Client::Endpoint#show
.
# File lib/hoodoo/services/middleware/endpoints/inter_resource_remote.rb, line 79 def show( ident, query_hash = nil ) result = preprocess( :show ) result = @wrapped_endpoint.show( ident, query_hash ) if result.nil? return postprocess( result ) end
See Hoodoo::Client::Endpoint#update
.
# File lib/hoodoo/services/middleware/endpoints/inter_resource_remote.rb, line 95 def update( ident, body_hash, query_hash = nil ) result = preprocess( :update ) result = @wrapped_endpoint.update( ident, body_hash, query_hash ) if result.nil? return postprocess( result ) end
Protected Instance Methods
See Hoodoo::Client::Endpoint#configure_with
.
It isn’t expected that anyone will ever need to use this class beyond Hoodoo::Services::Middleware
, but you never know…
Configuration option keys which must be supplied are:
interaction
-
A
Hoodoo::Services::Middleware::Interaction
instance which describes the source interaction at hand. This is a middleware concept; the middleware is handling some API call which the source interaction data describes, but the resource which is handling the call needs to make a remote inter-resource call, which is why this Endpoint subclass instance is needed. discovery_result
-
A
Hoodoo::Services::Discovery::ForRemote
instance describing the remotely available resource endpoint.
The pattern for creating and using this instance is:
-
Use the discovery result to build an appropriate Endpoint subclass instance, e.g.
Hoodoo::Client::Endpoint::HTTP
. -
Create a
Hoodoo::Services::Discovery::ForRemote
instance which describes the above endpoint via thewrapped_endpoint
option. -
Build an instance of this auto-session Endpoint subclass, giving it the above object as the
discovery_result
. -
Use this endpoint in the normal fashion. All the special mechanics of remote inter-resource calling are handled here.
# File lib/hoodoo/services/middleware/endpoints/inter_resource_remote.rb, line 63 def configure_with( resource, version, options ) @wrapped_endpoint = @discovery_result.wrapped_endpoint end