Class: Wines::ShowWine
- Inherits:
-
BaseUseCase
- Object
- BaseUseCase
- Wines::ShowWine
- Defined in:
- lib/winewoo_core/use_cases/wines/show_wine.rb
Instance Method Summary collapse
- #call(wine_id, options = {}) {|wine ? UseCaseResults.found(wine) : UseCaseResults.not_found| ... } ⇒ Object
-
#initialize(current_user, log_params = nil) ⇒ ShowWine
constructor
A new instance of ShowWine.
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
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, ={}) wine = self.repo.get(wine_id) return unless (wine, &Proc.new) wine = nil if wine && wine.draft? && [:only_published] # TODO UNOFFICIALS # wine = nil if wine && wine.unofficial? && options[:only_published] yield wine ? UseCaseResults.found(wine) : UseCaseResults.not_found end |