class WinewooCore::Repositories::Mongo::Queries::WineQuery
Public Class Methods
new(relation = Wine)
click to toggle source
Calls superclass method
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 4 def initialize(relation = Wine) super relation end
Public Instance Methods
count_all_vintages()
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 32 def count_all_vintages @relation.all.inject(0) do |total, wine| total += wine.vintages.length end end
drafts() { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 149 def drafts @relation = @relation .where(:status.ne => :published) block_given? ? @relation.each { |wine| yield wine } : self end
from_interpro(interpro_id) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 17 def from_interpro(interpro_id) @relation = @relation .where(interpro_id: interpro_id) block_given? ? @relation.each { |wine| yield wine } : self end
from_producer(producer_id) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 8 def from_producer(producer_id) @relation = @relation .where(producer_id: producer_id) block_given? ? @relation.each { |wine| yield wine } : self end
officials() { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 158 def officials @relation = @relation .where(unofficial: false) block_given? ? @relation.each { |wine| yield wine } : self end
percented_by(lower, higher) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 130 def percented_by(lower, higher) @relation = @relation .where(:computed_percent.gt => lower) .where(:computed_percent.lte => higher) block_given? ? @relation.each { |wine| yield wine } : self end
published() { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 140 def published @relation = @relation .where(:status => :published) block_given? ? @relation.each { |wine| yield wine } : self end
unofficials() { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 167 def unofficials @relation = @relation .where(unofficial: true) block_given? ? @relation.each { |wine| yield wine } : self end
with_appelation(appelation) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 78 def with_appelation(appelation) if appelation @relation = @relation .where(:appelation.in => appelation) block_given? ? @relation.each { |wine| yield wine } : self else self end end
with_colors(colors) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 65 def with_colors(colors) if colors @relation = @relation .any_in('color' => colors) block_given? ? @relation.each { |wine| yield wine } : self else self end end
with_grapes(grapes) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 91 def with_grapes(grapes) if grapes @relation = @relation .any_in('vintages.grapes.key' => grapes) block_given? ? @relation.each { |wine| yield wine } : self else self end end
with_label() { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 56 def with_label @relation = @relation .where(:vintages.elem_match => { :wine_label.exists => true }) block_given? ? @relation.each { |wine| yield wine } : self end
with_storage_duration(durations) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 104 def with_storage_duration(durations) if durations @relation = @relation .any_in('vintages.storage_duration' => durations) block_given? ? @relation.each { |wine| yield wine } : self else self end end
with_tasting_opportunities(opportunities) { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 117 def with_tasting_opportunities(opportunities) if opportunities @relation = @relation .any_in('vintages.tasting_opportunities' => opportunities) block_given? ? @relation.each { |wine| yield wine } : self else self end end
with_vintage_id(vintage_id)
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 26 def with_vintage_id(vintage_id) @relation .where('vintages._id' => vintage_id) .first end
without_label() { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 38 def without_label @relation = @relation .where(:vintages.elem_match => { :wine_label.exists => false }) block_given? ? @relation.each { |wine| yield wine } : self end
without_vintages() { |wine| ... }
click to toggle source
# File lib/winewoo_core/repositories/mongo/queries/wine_query.rb, line 47 def without_vintages @relation = @relation .where(:vintages.exists => false) block_given? ? @relation.each { |wine| yield wine } : self end