Module: Hope::Server::Helpers
- Defined in:
- lib/hope/server.rb
Instance Method Summary collapse
-
#body ⇒ Object
Request…
- #engine ⇒ Object
- #error_with(message, code = 400) ⇒ Object
-
#respond_with(d, code = 200) ⇒ Object
Response…
-
#statement ⇒ Object
Getters…
Instance Method Details
#body ⇒ Object
Request…
32 33 34 |
# File 'lib/hope/server.rb', line 32 def body @body ||= JSON.parse request.body.read rescue {} end |
#engine ⇒ Object
15 16 17 18 |
# File 'lib/hope/server.rb', line 15 def engine engine_id = params[:engine_id] || params[:id] Hope::Engine.get(engine_id) or not_found end |
#error_with(message, code = 400) ⇒ Object
27 28 29 |
# File 'lib/hope/server.rb', line 27 def error_with , code=400 respond_with({ :error => .to_s }, code) end |
#respond_with(d, code = 200) ⇒ Object
Response…
21 22 23 24 25 |
# File 'lib/hope/server.rb', line 21 def respond_with d, code=200 content_type :json status code d.to_json end |
#statement ⇒ Object
Getters…
10 11 12 13 |
# File 'lib/hope/server.rb', line 10 def statement statement_id = params[:statement_id] || params[:id] engine.statement(statement_id) or not_found end |