Class: WinewooCore::Repositories::Mongo::AwardMongoRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/winewoo_core/repositories/mongo/award_mongo_repo.rb

Instance Method Summary collapse

Instance Method Details

#create(wine_id, vintage_id, award_params) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/winewoo_core/repositories/mongo/award_mongo_repo.rb', line 4

def create(wine_id, vintage_id, award_params)
  return unless (wine_id && vintage_id)
  wine = Wine.find(wine_id)
  return unless wine
  vintage = wine.vintages.find(vintage_id)
  return unless vintage
  award = vintage.create_award(award_params)
  return award
end

#destroy(wine_id, vintage_id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/winewoo_core/repositories/mongo/award_mongo_repo.rb', line 28

def destroy(wine_id, vintage_id)
  return unless (wine_id && vintage_id)
  wine = Wine.find(wine_id)
  return unless wine
  vintage = wine.vintages.find(vintage_id)
  return unless vintage
  award = vintage.award
  return unless award
  award.destroy
  return award
end

#update(wine_id, vintage_id, award_params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/winewoo_core/repositories/mongo/award_mongo_repo.rb', line 15

def update(wine_id, vintage_id, award_params)
  return unless (wine_id && vintage_id)
  wine = Wine.find(wine_id)
  return unless wine
  vintage = wine.vintages.find(vintage_id)
  return unless vintage
  award = vintage.award
  return unless award
  award.update_attributes(award_params)
  return award
end