Class: GfreshPoint::Usecase::BaseUsecase
- Inherits:
-
Object
- Object
- GfreshPoint::Usecase::BaseUsecase
- Defined in:
- lib/gfresh_point/usecase/base_usecase.rb
Direct Known Subclasses
ConsumePointUsecase, EarnPointUsecase, FetchUserPointsUsecase, ListUserPointsUsecase, RuleListUsecase, UpdateRulePointUsecase
Instance Attribute Summary collapse
-
#repo ⇒ Object
or attr_reader ???.
Instance Method Summary collapse
- #call(request) ⇒ Object
- #execute(request) ⇒ Object
- #generate_response(result) ⇒ Object
-
#initialize(repo) ⇒ BaseUsecase
constructor
A new instance of BaseUsecase.
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
#repo ⇒ Object
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.) 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 |