Class: Neo4j::Core::CypherSession::Responses::HTTP
- Defined in:
- lib/neo4j/core/cypher_session/responses/http.rb
Instance Attribute Summary collapse
-
#request_data ⇒ Object
readonly
Returns the value of attribute request_data.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(faraday_response, request_data) ⇒ HTTP
constructor
A new instance of HTTP.
- #result_from_data(columns, entities_data) ⇒ Object
- #wrap_entity(row_data, rest_data) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(faraday_response, request_data) ⇒ HTTP
Returns a new instance of HTTP.
10 11 12 13 14 15 16 17 18 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 10 def initialize(faraday_response, request_data) @request_data = request_data validate_faraday_response!(faraday_response) @results = faraday_response.body[:results].map do |result_data| result_from_data(result_data[:columns], result_data[:data]) end end |
Instance Attribute Details
#request_data ⇒ Object (readonly)
Returns the value of attribute request_data.
8 9 10 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 8 def request_data @request_data end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
8 9 10 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 8 def results @results end |
Instance Method Details
#result_from_data(columns, entities_data) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 20 def result_from_data(columns, entities_data) rows = entities_data.map do |entity_data| wrap_entity entity_data[:row], entity_data[:rest] end Result.new(columns, rows) end |
#wrap_entity(row_data, rest_data) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 28 def wrap_entity(row_data, rest_data) row_data.each_with_index.map do |row_datum, i| rest_datum = rest_data[i] if rest_datum.is_a?(Array) wrap_entity(row_datum, rest_datum) elsif (ident = identify_entity(rest_datum)) send("wrap_#{ident}", rest_datum, row_datum) else row_datum end end end |