Class: Hanikamu::Service

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/hanikamu/service.rb

Overview

:nodoc

Constant Summary collapse

Error =
Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.call(options = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/hanikamu/service.rb', line 13

def call(options = {})
  Success(call!(options))
rescue StandardError => e
  return Failure.new(e) if whitelisted_error?(e.class)

  raise e
end

.call!(options = {}) ⇒ Object



21
22
23
# File 'lib/hanikamu/service.rb', line 21

def call!(options = {})
  options.empty? ? new.send(:call!) : new(options).send(:call!)
end