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, options = {}) ⇒ HTTP
constructor
A new instance of HTTP.
- #result_from_data(columns, entities_data) ⇒ Object
- #wrap_entity(row_datum, rest_datum) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(faraday_response, options = {}) ⇒ HTTP
Returns a new instance of HTTP.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 10 def initialize(faraday_response, = {}) @faraday_response = faraday_response @request_data = request_data validate_faraday_response!(faraday_response) @wrap_level = [:wrap_level] || Neo4j::Core::Config.wrapping_level @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
23 24 25 26 27 28 29 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 23 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_datum, rest_datum) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/neo4j/core/cypher_session/responses/http.rb', line 31 def wrap_entity(row_datum, rest_datum) if rest_datum.is_a?(Array) row_datum.zip(rest_datum).map { |row, rest| wrap_entity(row, rest) } elsif ident = identify_entity(rest_datum) send("wrap_#{ident}", rest_datum, row_datum) elsif rest_datum.is_a?(Hash) rest_datum.each_with_object({}) do |(k, v), result| result[k.to_sym] = wrap_entity(row_datum[k], v) end else row_datum end end |