Class: ApiResponse::Processor

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/api_response/processor.rb,
lib/api_response/processor/failure.rb,
lib/api_response/processor/success.rb

Defined Under Namespace

Classes: Failure, Success

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(response, options:, config: ApiResponse.config.dup) {|config| ... } ⇒ Object

Yields:

  • (config)


11
12
13
14
15
16
17
# File 'lib/api_response/processor.rb', line 11

def self.call(response, options:, config: ApiResponse.config.dup, &block)
  config = config.dup
  yield(config) if block
  config.update(options)

  new(response, config: config, options: options).call
end

Instance Method Details

#callObject



19
20
21
22
23
# File 'lib/api_response/processor.rb', line 19

def call
  processor = success? ? config.success_processor : config.failure_processor

  processor.new(response, config: config).call
end