Class: Vayacondios::Server::DocumentHandler
- Inherits:
-
Object
- Object
- Vayacondios::Server::DocumentHandler
- Includes:
- Goliath::Chimp::Handler
- Defined in:
- lib/vayacondios/server/handlers/document_handler.rb
Overview
Generic handler for all documents.
Handlers link HTTP applications to document classes.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#database ⇒ Driver
the database driver.
-
#log ⇒ Logger
the log to use.
Instance Method Summary collapse
- #action_successful ⇒ Object
-
#base_create(params, document) ⇒ Hash
Create a document.
-
#base_delete(params, document) ⇒ Hash
Delete a document.
-
#base_retrieve(params, document) ⇒ Object
Find and show a particular document.
-
#base_search(params, query) ⇒ Array<Hash>
Search for matching documents.
-
#base_update(params, document) ⇒ Object
Update a document.
- #call(name, params, document) ⇒ Object
-
#initialize(log, db) ⇒ DocumentHandler
constructor
Create a new DocumentHandler.
Constructor Details
#initialize(log, db) ⇒ DocumentHandler
Create a new DocumentHandler.
17 18 19 20 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 17 def initialize(log, db) @log = log @database = db end |
Instance Attribute Details
#database ⇒ Driver
the database driver
9 10 11 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 9 def database @database end |
#log ⇒ Logger
the log to use
9 10 11 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 9 def log @log end |
Instance Method Details
#action_successful ⇒ Object
77 78 79 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 77 def action_successful { ok: true } end |
#base_create(params, document) ⇒ Hash
Create a document.
37 38 39 40 41 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 37 def base_create(params, document) log.debug("Processing by #{self.class}#create") log.debug(" Parameters: #{params.inspect}") log.debug(" Document: #{document.inspect}") end |
#base_delete(params, document) ⇒ Hash
Delete a document.
67 68 69 70 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 67 def base_delete(params, document) log.debug("Processing by #{self.class}#delete") log.debug(" Parameters: #{params.inspect}") end |
#base_retrieve(params, document) ⇒ Object
Find and show a particular document.
47 48 49 50 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 47 def base_retrieve(params, document) log.debug("Processing by #{self.class}#retrieve") log.debug(" Parameters: #{params.inspect}") end |
#base_search(params, query) ⇒ Array<Hash>
Search for matching documents.
26 27 28 29 30 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 26 def base_search(params, query) log.debug("Processing by #{self.class}#search") log.debug(" Parameters: #{params.inspect}") log.debug(" Query: #{query.inspect}") end |
#base_update(params, document) ⇒ Object
Update a document.
57 58 59 60 61 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 57 def base_update(params, document) log.debug("Processing by #{self.class}#update") log.debug(" Parameters: #{params.inspect}") log.debug(" Document: #{document.inspect}") end |
#call(name, params, document) ⇒ Object
72 73 74 75 |
# File 'lib/vayacondios/server/handlers/document_handler.rb', line 72 def call(name, params, document) send("base_#{name}", params, document) send(name, params, document) end |