Skip to content

Commit

Permalink
Merge pull request maxdemarzi#77 from kamranjon/relation_factor
Browse files Browse the repository at this point in the history
adding config directory and env variables for deja
  • Loading branch information
kamranjon committed Dec 18, 2013
2 parents 652ab07 + e3dbca1 commit 149b2b2
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
55 changes: 55 additions & 0 deletions lib/config/graph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
development:
protocol: "http://"
server: "localhost"
port: 7474
directory: "" # prefix this path with '/'
cypher_path: "/cypher"
gremlin_path: "/ext/GremlinPlugin/graphdb/execute_script"
log_file: "neography.log"
log_enabled: true
max_threads: 20
authentication: nil # 'basic' or 'digest'
username: nil
password: nil
staging:
protocol: "http://"
server: "localhost"
port: 7474
directory: "" # prefix this path with '/'
cypher_path: "/cypher"
gremlin_path: "/ext/GremlinPlugin/graphdb/execute_script"
log_file: "neography.log"
log_enabled: false
slow_log_threshold: 0 # time in ms for query logging
max_threads: 20
authentication: nil # 'basic' or 'digest'
username: nil
password: nil
test:
protocol: "http://"
server: "localhost"
port: 7474
directory: "" # prefix this path with '/'
cypher_path: "/cypher"
gremlin_path: "/ext/GremlinPlugin/graphdb/execute_script"
log_file: "neography.log"
log_enabled: false
slow_log_threshold: 0 # time in ms for query logging
max_threads: 20
authentication: nil # 'basic' or 'digest'
username: nil
password: nil
production:
protocol: "http://"
server: "localhost"
port: 7474
directory: "" # prefix this path with '/'
cypher_path: "/cypher"
gremlin_path: "/ext/GremlinPlugin/graphdb/execute_script"
log_file: "neography.log"
log_enabled: false
slow_log_threshold: 0 # time in ms for query logging
max_threads: 20
authentication: nil # 'basic' or 'digest'
username: nil
password: nil
9 changes: 9 additions & 0 deletions lib/deja.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
require 'active_support'

require 'oj'
require 'yaml'

module Deja
extend ActiveSupport::Autoload

ENV['RAILS_ENV'] ||= 'development'

autoload :RestIndex
autoload :Node
autoload :Cast
Expand All @@ -36,6 +39,12 @@ module Deja

class << self; attr_accessor :neo, :tx, :batch ; end

config_hash = YAML.load_file("#{File.dirname(File.expand_path(__FILE__))}/config/graph.yml")
Neography.configure do |config|
config_hash[ENV['RAILS_ENV']].each do |k, v|
config.send("#{k}=".to_sym, v)
end
end
Deja.neo = Neography::Rest.new()
Deja.set_node_auto_index_status(true)
Deja.set_relationship_auto_index_status(true)
Expand Down
5 changes: 3 additions & 2 deletions lib/deja/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ def create!

def update!(opts = {})
opts.each { |attribute, value| send("#{attribute}=", value) }
updated_node = nil
run_callbacks :save do
run_callbacks :update do
Deja::Query.update_node(@id, persisted_attributes)
updated_node = Deja::Query.update_node(@id, persisted_attributes)
self.class.objectify(updated_node)
end
end
self
end

def destroy
Expand Down
2 changes: 1 addition & 1 deletion lib/deja/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def delete_node(node_id)
def update_node(node_id, attributes = {})
cypher_query = Deja::Bridge.update_node(node_id, attributes)
result_hash = Deja.execute_cypher(cypher_query)
result_hash["data"].empty? ? false : true
normalize(result_hash)
end

def count_nodes(index)
Expand Down

0 comments on commit 149b2b2

Please sign in to comment.