Class: GfreshPoint::Usecase::BaseUsecase

Inherits:
Object
  • Object
show all
Defined in:
lib/gfresh_point/usecase/base_usecase.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ BaseUsecase

Returns a new instance of BaseUsecase.



6
7
8
# File 'lib/gfresh_point/usecase/base_usecase.rb', line 6

def initialize( repo)
  @repo = repo
end

Instance Attribute Details

#repoObject

or attr_reader ???



4
5
6
# File 'lib/gfresh_point/usecase/base_usecase.rb', line 4

def repo
  @repo
end

Instance Method Details

#call(request) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/gfresh_point/usecase/base_usecase.rb', line 10

def call(request)
  if request.success?
    result = execute(request)
    generate_response(result)
  else
    GfreshPoint::ResponseObjects::ResponseFailure.new(GfreshPoint::ResponseObjects::ResponseFailure::PARAMETERS_ERROR, request.errors)
  end
rescue StandardError => e
  GfreshPoint::ResponseObjects::ResponseFailure.new(GfreshPoint::ResponseObjects::ResponseFailure::SYSTEM_ERROR, e.message)
end

#execute(request) ⇒ Object



25
26
27
# File 'lib/gfresh_point/usecase/base_usecase.rb', line 25

def execute(request)
  raise "Not impl"
end

#generate_response(result) ⇒ Object



21
22
23
# File 'lib/gfresh_point/usecase/base_usecase.rb', line 21

def generate_response(result)
  GfreshPoint::ResponseObjects::ResponseSuccess.new(result)
end