Class: Trailblazer::Endpoint
- Inherits:
-
Object
- Object
- Trailblazer::Endpoint
- Defined in:
- lib/trailblazer/endpoint.rb
Overview
Encapsulates HTTP-specific logic needed before running an operation. Right now, all this does is #document_body! which figures out whether or not to pass the request body into params, so the operation can use a representer to deserialize the original document. To be used in Lotus, Roda, Rails, etc.
Instance Method Summary collapse
- #call {|@params| ... } ⇒ Object
-
#initialize(operation_class, params, request, options) ⇒ Endpoint
constructor
A new instance of Endpoint.
Constructor Details
#initialize(operation_class, params, request, options) ⇒ Endpoint
Returns a new instance of Endpoint.
7 8 9 10 11 12 |
# File 'lib/trailblazer/endpoint.rb', line 7 def initialize(operation_class, params, request, ) @operation_class = operation_class @params = params @request = request @is_document = document_request_for?() end |
Instance Method Details
#call {|@params| ... } ⇒ Object
14 15 16 17 |
# File 'lib/trailblazer/endpoint.rb', line 14 def call document_body! if @is_document yield @params# Create.run(params) end |