class Neo4j::Config

Keeps configuration for neo4j

Configurations keys

Constants

DEFAULT_FILE

Public Class Methods

[](key) click to toggle source

@param [Symbol] key The key of the config entry value we want @return the the value of a config entry

   # File lib/neo4j/config.rb
69 def [](key)
70   configuration[key.to_s]
71 end
[]=(key, val) click to toggle source

Sets the value of a config entry.

@param [Symbol] key the key to set the parameter for @param val the value of the parameter.

   # File lib/neo4j/config.rb
63 def []=(key, val)
64   configuration[key.to_s] = val
65 end
association_model_namespace() click to toggle source
    # File lib/neo4j/config.rb
120 def association_model_namespace
121   Neo4j::Config[:association_model_namespace] || nil
122 end
association_model_namespace_string() click to toggle source
    # File lib/neo4j/config.rb
124 def association_model_namespace_string
125   namespace = Neo4j::Config[:association_model_namespace]
126   return nil if namespace.nil?
127   "::#{namespace}"
128 end
configuration() click to toggle source

Reads from the default_file if configuration is not set already @return [Hash] the configuration

   # File lib/neo4j/config.rb
35 def configuration
36   return @configuration if @configuration
37 
38   @configuration = ActiveSupport::HashWithIndifferentAccess.new
39   @configuration.merge!(defaults)
40   @configuration
41 end
default_file() click to toggle source

@return [Integer] The location of the default configuration file.

   # File lib/neo4j/config.rb
15 def default_file
16   @default_file ||= DEFAULT_FILE
17 end
default_file=(file_path) click to toggle source

Sets the location of the configuration YAML file and old deletes configurations. @param [String] file_path represent the path to the file.

   # File lib/neo4j/config.rb
21 def default_file=(file_path)
22   delete_all
23   @defaults = nil
24   @default_file = File.expand_path(file_path)
25 end
defaults() click to toggle source

@return [Hash] the default file loaded by yaml

   # File lib/neo4j/config.rb
28 def defaults
29   require 'yaml'
30   @defaults ||= ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(default_file))
31 end
delete(key) click to toggle source

Remove the value of a config entry.

@param [Symbol] key the key of the configuration entry to delete @return The value of the removed entry.

   # File lib/neo4j/config.rb
81 def delete(key)
82   configuration.delete(key)
83 end
delete_all() click to toggle source

Remove all configuration. This can be useful for testing purpose.

@return nil

   # File lib/neo4j/config.rb
88 def delete_all
89   @configuration = nil
90 end
enums_case_sensitive() click to toggle source
    # File lib/neo4j/config.rb
130 def enums_case_sensitive
131   Neo4j::Config[:enums_case_sensitive] || false
132 end
fail_on_pending_migrations() click to toggle source
    # File lib/neo4j/config.rb
102 def fail_on_pending_migrations
103   Neo4j::Config[:fail_on_pending_migrations].nil? ? true : Neo4j::Config[:fail_on_pending_migrations]
104 end
fetch(key, default) click to toggle source
   # File lib/neo4j/config.rb
73 def fetch(key, default)
74   configuration.fetch(key, default)
75 end
include_root_in_json() click to toggle source
    # File lib/neo4j/config.rb
106 def include_root_in_json
107   # we use ternary because a simple || will always evaluate true
108   Neo4j::Config[:include_root_in_json].nil? ? true : Neo4j::Config[:include_root_in_json]
109 end
module_handling() click to toggle source
    # File lib/neo4j/config.rb
111 def module_handling
112   Neo4j::Config[:module_handling] || :none
113 end
timestamp_type() click to toggle source

@return [Class] The configured timestamps type (e.g. Integer) or the default DateTime.

    # File lib/neo4j/config.rb
116 def timestamp_type
117   Neo4j::Config[:timestamp_type] || DateTime
118 end
to_hash() click to toggle source

@return [Hash] The config as a hash.

   # File lib/neo4j/config.rb
93 def to_hash
94   configuration.to_hash
95 end
to_yaml() click to toggle source

@return [String] The config as a YAML

    # File lib/neo4j/config.rb
 98 def to_yaml
 99   configuration.to_yaml
100 end
use() { |configuration| ... } click to toggle source

Yields the configuration

@example

Neo4j::Config.use do |config|
  config[:storage_path] = '/var/neo4j'
end

@return nil @yield config @yieldparam [Neo4j::Config] config - this configuration class

   # File lib/neo4j/config.rb
53 def use
54   @configuration ||= ActiveSupport::HashWithIndifferentAccess.new
55   yield @configuration
56   nil
57 end