Class: Wines::ShowVintage

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

Instance Method Summary collapse

Constructor Details

#initialize(current_user, log_params = nil) ⇒ ShowVintage

Returns a new instance of ShowVintage.



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

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

Instance Method Details

#call(wine_id, vintage_id, options = {}) {|vintage ? UseCaseResults.found(vintage) : 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_vintage.rb', line 10

def call(wine_id, vintage_id, options={})
  wine = WinewooCore.wines_repo.new.get(wine_id)
  return unless authorize_vintage_show(wine, &Proc.new)

  vintage = self.repo.get(wine_id, vintage_id)
  vintage = nil if wine && wine.draft? && options[:only_published]
  # TODO UNOFFICIALS
  # vintage = nil if wine && wine.unofficial? && options[:only_published]

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