Skip to content

Commit

Permalink
Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerfulstoic committed Aug 7, 2015
1 parent 72faf33 commit da37bb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/neo4j-server/cypher_relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def update_props(properties)
return if properties.empty?

params = {}
q = "#{match_start} SET " + properties.keys.each_with_index.map do |k, i|
q = "#{match_start} SET " + properties.keys.each_with_index.map do |k, _i|
param = k.to_s.tr_s('^a-zA-Z0-9', '_').gsub(/^_+|_+$/, '')
params[param] = properties[k]

Expand Down
13 changes: 5 additions & 8 deletions lib/neo4j-server/cypher_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,14 @@ def begin_tx
end

def create_node(props = nil, labels = [])
label_string = labels.empty? ? '' : (":" + labels.map { |k| "`#{k}`" }.join(':'))
label_string = labels.empty? ? '' : (':' + labels.map { |k| "`#{k}`" }.join(':'))
if !props.nil?
prop_identifier = '{props}'
prop = '{props}'
props.each_key { |k| props.delete(k) if props[k].nil? }
end
cypher_string = "CREATE (n#{label_string} #{prop_identifier}) RETURN ID(n)"

id = _query_or_fail(cypher_string, true, props: props)
value = props.nil? ? id : {id: id, metadata: {labels: labels}, data: props}
CypherNode.new(self, value)
id = _query_or_fail("CREATE (n#{label_string} #{prop}) RETURN ID(n)", true, props: props)
CypherNode.new(self, props.nil? ? id : {id: id, metadata: {labels: labels}, data: props})
end

def load_node(neo_id)
Expand Down Expand Up @@ -215,9 +213,8 @@ def _query(query, params = {}, options = {})
if curr_tx
curr_tx._query(query, params)
else
url = resource_url(:cypher)
query = params.nil? ? {'query' => query} : {'query' => query, 'params' => params}
response = @connection.post(url, query)
response = @connection.post(resource_url(:cypher), query)
CypherResponse.create_with_no_tx(response)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/neo4j-core/unit/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def self.it_generates(cypher, params = {})
it_generates 'WHERE (q.age = {q_age} AND q.name = {q_name}) AND (r.grade = 80)', q_age: 30, q_name: 'Brian'
end

describe ".where(q: {name: /Brian.*/i})" do
describe '.where(q: {name: /Brian.*/i})' do
it_generates 'WHERE (q.name =~ {q_name})', q_name: '(?i)Brian.*'
end

Expand Down

0 comments on commit da37bb4

Please sign in to comment.