Class: Trailblazer::V1_1::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/1.1/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 Hanami, Roda, Rails, etc.

Instance Method Summary collapse

Constructor Details

#initialize(operation_class, params, request, options) ⇒ Endpoint

Returns a new instance of Endpoint.


7
8
9
10
11
12
# File 'lib/trailblazer/1.1/endpoint.rb', line 7

def initialize(operation_class, params, request, options)
  @operation_class = operation_class
  @params          = params
  @request         = request
  @is_document     = options[:is_document]
end

Instance Method Details

#call {|@params| ... } ⇒ Object

Yields:

  • (@params)

14
15
16
17
# File 'lib/trailblazer/1.1/endpoint.rb', line 14

def call
  document_body! if @is_document
  yield @params# Create.run(params)
end