Class: WinewooUser::Logs::CreateWinewooUserLog

Inherits:
BaseUseCase
  • Object
show all
Defined in:
lib/winewoo_core/use_cases/winewoo_user/logs/create_winewoo_user_log.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_params = nil) ⇒ CreateWinewooUserLog

Returns a new instance of CreateWinewooUserLog.



4
5
6
# File 'lib/winewoo_core/use_cases/winewoo_user/logs/create_winewoo_user_log.rb', line 4

def initialize(log_params=nil)
  super(WinewooCore.winewoo_user_logs_repo.new, log_params)
end

Instance Method Details

#call(log_params) {|log.persisted? ? UseCaseResults.success(log) : UseCaseResults.failure(log.errors)| ... } ⇒ Object

Yields:



9
10
11
12
13
14
15
# File 'lib/winewoo_core/use_cases/winewoo_user/logs/create_winewoo_user_log.rb', line 9

def call(log_params)
  log = self.repo.create(log_params)

  yield log.persisted? ?
    UseCaseResults.success(log) :
    UseCaseResults.failure(log.errors)
end