class WinewooCore::Repositories::Mongo::VintagesMongoRepo
Public Instance Methods
create(current_user, wine_id, vintage_params)
click to toggle source
# File lib/winewoo_core/repositories/mongo/vintages_mongo_repo.rb, line 20 def create(current_user, wine_id, vintage_params) return unless wine_id wine = Wine.find(wine_id) return unless wine vintage = wine.vintages.build vintage.modified_by = current_user.id vintage.embedded_in = wine.id vintage.update_attributes(vintage_params) return vintage end
destroy(current_user, wine_id, vintage_id)
click to toggle source
# File lib/winewoo_core/repositories/mongo/vintages_mongo_repo.rb, line 45 def destroy(current_user, 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 vintage.modified_by = current_user.id vintage.embedded_in = wine.id vintage.destroy return vintage end
find(wine_id)
click to toggle source
# File lib/winewoo_core/repositories/mongo/vintages_mongo_repo.rb, line 12 def find(wine_id) return unless wine_id wine = Wine.find(wine_id) return unless wine wine.vintages end
get(wine_id, vintage_id)
click to toggle source
# File lib/winewoo_core/repositories/mongo/vintages_mongo_repo.rb, line 4 def get(wine_id, vintage_id) return unless (wine_id && vintage_id) wine = Wine.find(wine_id) return unless wine wine.vintages.find(vintage_id) end
update(current_user, wine_id, vintage_id, vintage_params)
click to toggle source
# File lib/winewoo_core/repositories/mongo/vintages_mongo_repo.rb, line 32 def update(current_user, wine_id, vintage_id, vintage_params) return unless wine_id wine = Wine.find(wine_id) return unless wine vintage = wine.vintages.find(vintage_id) vintage.modified_by = current_user.id vintage.embedded_in = wine.id vintage.unofficial = false vintage.update_attributes(vintage_params) return vintage end