Skip to content

Commit

Permalink
Rubocop
Browse files Browse the repository at this point in the history
(cherry picked from commit 6cd8ca8)
  • Loading branch information
cheerfulstoic committed Dec 18, 2015
1 parent 0341547 commit 6f0f966
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/neo4j-core/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ class << self
end

def initialize(options = {})
@session = options[:session]
@session = Neo4j::Session.current if !options.key?(:session)
@session = options.key?(:session) ? options[:session] : Neo4j::Session.current

@options = options
@clauses = []
Expand Down Expand Up @@ -226,13 +225,17 @@ def unwrapped?
!!@_unwrapped_obj
end

def session_is_new_api?
defined?(::Neo4j::Core::CypherSession) && @session.is_a?(::Neo4j::Core::CypherSession)
end

def response
return @response if @response

cypher = to_cypher
pretty_cypher = to_cypher(pretty: true) if self.class.pretty_cypher

@response = if defined?(::Neo4j::Core::CypherSession) && @session.is_a?(::Neo4j::Core::CypherSession)
@response = if session_is_new_api?
@session.query(self)
else
@session._query(cypher, merge_params, context: @options[:context], pretty_cypher: pretty_cypher)
Expand Down

0 comments on commit 6f0f966

Please sign in to comment.