Class: Users::ShowUser

Inherits:
BaseUseCase
  • Object
show all
Defined in:
lib/winewoo_core/use_cases/users/show_user.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, log_params = nil) ⇒ ShowUser

Returns a new instance of ShowUser.



4
5
6
7
# File 'lib/winewoo_core/use_cases/users/show_user.rb', line 4

def initialize(current_user, log_params=nil)
  super(WinewooCore.users_repo.new, log_params)
  self.current_caller = current_user
end

Instance Method Details

#call(user_id) {|user ? UseCaseResults.found(user) : UseCaseResults.not_found| ... } ⇒ Object

Yields:



10
11
12
13
14
15
16
17
18
# File 'lib/winewoo_core/use_cases/users/show_user.rb', line 10

def call(user_id)
  user = (user_id == 'me') ? self.current_caller : self.repo.get(user_id)

  return unless authorize_user_show(user, &Proc.new)

  yield user ?
    UseCaseResults.found(user) :
    UseCaseResults.not_found
end