Class: Wine
- Inherits:
-
Object
- Object
- Wine
- Includes:
- ActiveModel::ForbiddenAttributesProtection, Concerns::Percentable, Concerns::Trackable, Mongoid::Document, Mongoid::Search, Mongoid::Timestamps
- Defined in:
- app/models/wine.rb
Direct Known Subclasses
Instance Method Summary collapse
- #all_vintages_labeled? ⇒ Boolean
- #draft? ⇒ Boolean
- #official? ⇒ Boolean
- #publish! ⇒ Object
- #published? ⇒ Boolean
- #unofficial? ⇒ Boolean
Instance Method Details
#all_vintages_labeled? ⇒ Boolean
107 108 109 110 111 112 |
# File 'app/models/wine.rb', line 107 def all_vintages_labeled? c = self.vintages.inject(0) do |count, v| (v.wine_label && v.wine_label.url) ? count + 1 : count end c == self.vintages.size end |
#draft? ⇒ Boolean
83 84 85 |
# File 'app/models/wine.rb', line 83 def draft? self.status != :published end |
#official? ⇒ Boolean
87 88 89 |
# File 'app/models/wine.rb', line 87 def official? !self.unofficial end |
#publish! ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'app/models/wine.rb', line 97 def publish! # save # if computed_percent >= 50 # self.status = :published # save # end self.set(status: :published) end |
#published? ⇒ Boolean
78 79 80 |
# File 'app/models/wine.rb', line 78 def published? self.status == :published end |
#unofficial? ⇒ Boolean
92 93 94 |
# File 'app/models/wine.rb', line 92 def unofficial? self.unofficial end |