Class: Vayacondios::Server::StashHandler
- Inherits:
-
DocumentHandler
- Object
- DocumentHandler
- Vayacondios::Server::StashHandler
- Defined in:
- lib/vayacondios/server/handlers/stash_handler.rb
Instance Attribute Summary
Attributes inherited from DocumentHandler
Instance Method Summary collapse
-
#create(params, document) ⇒ Object
Create a stash.
-
#delete(params, document) ⇒ Object
Delete a single stash.
-
#retrieve(params, document) ⇒ Object
Find and show a particular stash.
Methods inherited from DocumentHandler
#action_successful, #base_create, #base_delete, #base_retrieve, #base_search, #base_update, #call, #initialize
Constructor Details
This class inherits a constructor from Vayacondios::Server::DocumentHandler
Instance Method Details
#create(params, document) ⇒ Object
Create a stash.
8 9 10 11 12 13 14 |
# File 'lib/vayacondios/server/handlers/stash_handler.rb', line 8 def create(params, document) stash = Stash.create(params, document) do |request| database.call(:insert, request) end stash.delete(:topic) stash end |
#delete(params, document) ⇒ Object
Delete a single stash.
61 62 63 64 65 66 67 |
# File 'lib/vayacondios/server/handlers/stash_handler.rb', line 61 def delete(params, document) raise Goliath::Validation::NotImplementedError.new 'Deleting an Id from a Stash is not supported' if params[:id] Stash.destroy(params, {}) do |request, | database.call(:remove, request, ) end action_successful end |
#retrieve(params, document) ⇒ Object
Find and show a particular stash.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vayacondios/server/handlers/stash_handler.rb', line 20 def retrieve(params, document) stash = Stash.find(params) do |request| database.call(:retrieve, request) end or raise Goliath::Validation::NotFoundError.new("Stash with topic <#{params[:topic]}> not found") stash.delete(:topic) if slice = params[:id] stash[slice.to_sym] or raise Goliath::Validation::NotFoundError.new("Stash with topic <#{params[:topic]}> found, but does not contain Id <#{slice}>") else stash end end |