Class: WebFetch::Resources
- Inherits:
-
Object
- Object
- WebFetch::Resources
- Defined in:
- lib/web_fetch/resources.rb
Overview
Glue between the router and the guts of the application; calls the relevant code and builds responses
Class Method Summary collapse
- .find(server, params) ⇒ Object
- .gather(server, params) ⇒ Object
- .retrieve(server, params, options = {}) ⇒ Object
- .root(_server, _params) ⇒ Object
Class Method Details
.find(server, params) ⇒ Object
35 36 37 |
# File 'lib/web_fetch/resources.rb', line 35 def find(server, params) retrieve(server, params, block: false) end |
.gather(server, params) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/web_fetch/resources.rb', line 16 def gather(server, params) gatherer = Gatherer.new(server.storage, params) if gatherer.valid? { status: status(:ok), payload: gatherer.start, command: 'gather' } else { status: status(:unprocessable), payload: { error: gatherer.errors }, command: 'gather' } end end |
.retrieve(server, params, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/web_fetch/resources.rb', line 26 def retrieve(server, params, = {}) retriever = Retriever.new(server.storage, params, ) unless retriever.valid? return { status: status(:unprocessable), command: 'retrieve', payload: { error: retriever.errors } } end defer_if_found(retriever) end |
.root(_server, _params) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/web_fetch/resources.rb', line 8 def root(_server, _params) { status: status(:ok), command: 'root', payload: { application: 'WebFetch' } } end |