Class: Wines::ShowWine

Inherits:
BaseUseCase
  • Object
show all
Defined in:
lib/winewoo_core/use_cases/wines/show_wine.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, log_params = nil) ⇒ ShowWine

Returns a new instance of ShowWine.



4
5
6
7
# File 'lib/winewoo_core/use_cases/wines/show_wine.rb', line 4

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

Instance Method Details

#call(wine_id, options = {}) {|wine ? UseCaseResults.found(wine) : UseCaseResults.not_found| ... } ⇒ Object

Yields:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/winewoo_core/use_cases/wines/show_wine.rb', line 10

def call(wine_id, options={})
  wine = self.repo.get(wine_id)

  return unless authorize_wine_show(wine, &Proc.new)

  wine = nil if wine && wine.draft? && options[:only_published]
  # TODO UNOFFICIALS
  # wine = nil if wine && wine.unofficial? && options[:only_published]

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