Class: WinewooCore::Repositories::Mongo::CellarMongoRepo
- Inherits:
-
Object
- Object
- WinewooCore::Repositories::Mongo::CellarMongoRepo
- Defined in:
- lib/winewoo_core/repositories/mongo/cellar_mongo_repo.rb
Instance Method Summary collapse
- #create(winewoo_user, entry_params) ⇒ Object
- #destroy(winewoo_user, entry_id) ⇒ Object
- #find(winewoo_user, filters) ⇒ Object
- #update(winewoo_user, entry_id, entry_params) ⇒ Object
Instance Method Details
#create(winewoo_user, entry_params) ⇒ Object
14 15 16 |
# File 'lib/winewoo_core/repositories/mongo/cellar_mongo_repo.rb', line 14 def create(winewoo_user, entry_params) winewoo_user.cellar_entries.create(entry_params) end |
#destroy(winewoo_user, entry_id) ⇒ Object
33 34 35 36 37 |
# File 'lib/winewoo_core/repositories/mongo/cellar_mongo_repo.rb', line 33 def destroy(winewoo_user, entry_id) entry = winewoo_user.cellar_entries.find(entry_id) entry.destroy if entry return entry end |
#find(winewoo_user, filters) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/winewoo_core/repositories/mongo/cellar_mongo_repo.rb', line 4 def find(winewoo_user, filters) # TODO UNOFFICIALS # winewoo_user.cellar_entries.map do |entry| # wine = Wine.find entry.wine_id # entry if wine && wine.official? # end.reject(&:blank?) winewoo_user.cellar_entries end |
#update(winewoo_user, entry_id, entry_params) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/winewoo_core/repositories/mongo/cellar_mongo_repo.rb', line 19 def update(winewoo_user, entry_id, entry_params) entry = winewoo_user.cellar_entries.find(entry_id) # TODO UNOFFICIALS # if entry # wine = Wine.find entry.wine_id # entry = nil if wine && wine.unofficial? # end entry.update_attributes(entry_params) if entry return entry end |