lib/n4j/cypher.rb in n4j-0.0.1.3 vs lib/n4j/cypher.rb in n4j-0.0.1.4
- old
+ new
@@ -1,7 +1,7 @@
class N4j::Cypher
- PARAMETERS = [:start, :match, :where, :return]
+ PARAMETERS = [:start, :match, :where, :return, :instantiate_with]
attr_accessor *PARAMETERS
def initialize(opts ={})
opts.each_pair do |k,v|
send "#{k}=", v if respond_to?("#{k}=")
@@ -16,19 +16,24 @@
def start=(entity)
@start = if entity.kind_of?(String)
entity
else
+ @hint_klass = entity.class
"start a = #{entity.entity_type}(#{entity.to_key.first})"
end
end
def return
@return || (match && "return #{match.split(/\W+/).last}")
end
def go
- self.class.query(to_query)
+ result = self.class.query(to_query)
+ result['data'].collect do |from_neo4j|
+ (instantiate_with || GenericNode).new(from_neo4j.first)
+ # GenericNode.new(from_neo4j.first)
+ end
end
def to_query
raise "start must contain 'start' (currently: '#{start}')" if start && !start.index('start')
raise "match must contain 'match' (currently: '#{match}')" if match && !match.index('match')
\ No newline at end of file