Class: Qravan::Query
- Inherits:
-
Object
- Object
- Qravan::Query
- Defined in:
- lib/qravan/query.rb
Overview
Sources for data extractions class
Instance Attribute Summary collapse
-
#cargo ⇒ Object
Returns the value of attribute cargo.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(cargo) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(cargo) ⇒ Query
Returns a new instance of Query.
14 15 16 |
# File 'lib/qravan/query.rb', line 14 def initialize(cargo) @cargo ||= cargo end |
Instance Attribute Details
#cargo ⇒ Object
Returns the value of attribute cargo.
12 13 14 |
# File 'lib/qravan/query.rb', line 12 def cargo @cargo end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/qravan/query.rb', line 18 def call(env) query = Rack::Request.new(env) request = Qravan::Request.new(JSON.parse(query.body.read), cargo) response = Qravan::Response.new(request) body = [response.answer] status = 200 headers = { "content-type" => "application/json" } [status, headers, body] end |