Class: Wine

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::ForbiddenAttributesProtection, Concerns::Percentable, Concerns::Trackable, Mongoid::Document, Mongoid::Search, Mongoid::Timestamps
Defined in:
app/models/wine.rb

Direct Known Subclasses

UnofficialWine

Instance Method Summary collapse

Instance Method Details

#all_vintages_labeled?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


83
84
85
# File 'app/models/wine.rb', line 83

def draft?
  self.status != :published
end

#official?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


78
79
80
# File 'app/models/wine.rb', line 78

def published?
  self.status == :published
end

#unofficial?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'app/models/wine.rb', line 92

def unofficial?
  self.unofficial
end