Class: Vayacondios::Server::EventHandler
- Inherits:
-
DocumentHandler
- Object
- DocumentHandler
- Vayacondios::Server::EventHandler
- Defined in:
- lib/vayacondios/server/handlers/event_handler.rb
Instance Attribute Summary
Attributes inherited from DocumentHandler
Instance Method Summary collapse
-
#create(params, document) ⇒ Object
Create an event.
-
#delete(params, document) ⇒ Object
Delete a specific event.
-
#retrieve(params, document) ⇒ Object
Find and show a particular event.
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 an event.
8 9 10 11 12 |
# File 'lib/vayacondios/server/handlers/event_handler.rb', line 8 def create(params, document) Event.create(params, document) do |request| database.call(:insert, request) end end |
#delete(params, document) ⇒ Object
Delete a specific event.
30 31 32 33 34 35 36 |
# File 'lib/vayacondios/server/handlers/event_handler.rb', line 30 def delete(params, document) raise Goliath::Validation::BadRequestError.new('An <Id> is required to delete an Event') unless params[:id] Event.destroy(params, {}) do |request, | database.call(:remove, request, ) end action_successful end |
#retrieve(params, document) ⇒ Object
Find and show a particular event.
19 20 21 22 23 |
# File 'lib/vayacondios/server/handlers/event_handler.rb', line 19 def retrieve(params, document) Event.find(params) do |request| database.call(:retrieve, request) end or raise Goliath::Validation::NotFoundError.new("Event with topic <#{params[:topic]}> and ID <#{params[:id]}> not found") end |