Class: Neo4j::Config
- Inherits:
-
Object
- Object
- Neo4j::Config
- Defined in:
- lib/neo4j/config.rb
Overview
Keeps configuration for neo4j
The most important configuration is storage_path which is used to locate where the neo4j database is stored on the filesystem. If this directory is empty then a new database will be created, otherwise it will use the database from that directory.
Configurations keys
storage_path where the database is stored
enable_ha if ha cluster should be enabled (requires neo4j-enterprise gem)
timestamps if timestamps should be used when saving the model (Neo4j::Rails::Model)
lucene lucene configuration for fulltext and exact indices
enable_rules if false the _all relationship to all instances will not be created and custom rules will not be available. (Neo4j::NodeMixin and Neo4j::Rails::Model)
identity_map default false, See Neo4j::IdentityMap (Neo4j::NodeMixin and Neo4j::Rails::Model)
Class Method Summary (collapse)
-
+ (Object) [](key)
The the value of a config entry.
-
+ (Object) []=(key, val)
Sets the value of a config entry.
-
+ (Fixnum) default_file
The location of the default configuration file.
-
+ (Object) default_file=(file_path)
Sets the location of the configuration YAML file and old deletes configurations.
-
+ (Hash) defaults
The default file loaded by yaml.
-
+ (Object) delete(key)
Remove the value of a config entry.
-
+ (Object) delete_all
Remove all configuration.
-
+ (Object) setup
The a new configuration using default values as a hash.
-
+ (String) storage_path
The expanded path of the Config property.
-
+ (Hash) to_hash
The config as a hash.
-
+ (Object) to_java_map
Converts the defaults hash to a Java HashMap used by the Neo4j API.
-
+ (String) to_yaml
The config as a YAML.
-
+ (Object) use {|config| ... }
Yields the configuration.
Class Method Details
+ (Object) [](key)
The the value of a config entry
77 78 79 |
# File 'lib/neo4j/config.rb', line 77 def [](key) (@configuration ||= setup)[key.to_s] end |
+ (Object) []=(key, val)
Sets the value of a config entry.
70 71 72 |
# File 'lib/neo4j/config.rb', line 70 def []=(key, val) (@configuration ||= setup)[key.to_s] = val end |
+ (Fixnum) default_file
The location of the default configuration file.
25 26 27 |
# File 'lib/neo4j/config.rb', line 25 def default_file @default_file ||= File.(File.join(File.dirname(__FILE__), "..", "..", "config", "neo4j", "config.yml")) end |
+ (Object) default_file=(file_path)
Sets the location of the configuration YAML file and old deletes configurations.
32 33 34 35 36 |
# File 'lib/neo4j/config.rb', line 32 def default_file=(file_path) @configuration = nil @defaults = nil @default_file = File.(file_path) end |
+ (Hash) defaults
The default file loaded by yaml
39 40 41 42 |
# File 'lib/neo4j/config.rb', line 39 def defaults require 'yaml' @defaults ||= Neo4j::Core::HashWithIndifferentAccess.new(YAML.load_file(default_file)) end |
+ (Object) delete(key)
Remove the value of a config entry.
86 87 88 |
# File 'lib/neo4j/config.rb', line 86 def delete(key) @configuration.delete(key) end |
+ (Object) delete_all
Remove all configuration. This can be useful for testing purpose.
94 95 96 |
# File 'lib/neo4j/config.rb', line 94 def delete_all @configuration = nil end |
+ (Object) setup
The a new configuration using default values as a hash.
128 129 130 131 132 |
# File 'lib/neo4j/config.rb', line 128 def setup() @configuration = Neo4j::Core::HashWithIndifferentAccess.new @configuration.merge!(defaults) @configuration end |
+ (String) storage_path
The expanded path of the Config property
45 46 47 |
# File 'lib/neo4j/config.rb', line 45 def storage_path File.(self[:storage_path]) end |
+ (Hash) to_hash
The config as a hash.
100 101 102 |
# File 'lib/neo4j/config.rb', line 100 def to_hash @configuration ||= setup end |
+ (Object) to_java_map
Converts the defaults hash to a Java HashMap used by the Neo4j API.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/neo4j/config.rb', line 111 def to_java_map map = java.util.HashMap.new to_hash.each_pair do |k, v| case v when TrueClass map[k.to_s] = "true" when FalseClass map[k.to_s] = "false" when String, Fixnum, Float map[k.to_s] = v.to_s # skip list and hash values - not accepted by the Java Neo4j API end end map end |
+ (String) to_yaml
The config as a YAML
105 106 107 |
# File 'lib/neo4j/config.rb', line 105 def to_yaml @configuration.to_yaml end |
+ (Object) use {|config| ... }
Yields the configuration
59 60 61 62 63 |
# File 'lib/neo4j/config.rb', line 59 def use @configuration ||= Neo4j::Core::HashWithIndifferentAccess.new yield @configuration nil end |