Class: Neo4j::Config
- Inherits:
-
Object
- Object
- Neo4j::Config
- Defined in:
- lib/neo4j/config.rb
Overview
Keeps configuration for neo4j
Configurations keys
Constant Summary collapse
- DEFAULT_FILE =
File.(File.join(File.dirname(__FILE__), '..', '..', 'config', 'neo4j', 'config.yml'))
- CLASS_NAME_PROPERTY_KEY =
'class_name_property'
Class Method Summary collapse
-
.[](key) ⇒ Object
The the value of a config entry.
-
.[]=(key, val) ⇒ Object
Sets the value of a config entry.
- .association_model_namespace ⇒ Object
- .association_model_namespace_string ⇒ Object
-
.configuration ⇒ Hash
Reads from the default_file if configuration is not set already.
-
.default_file ⇒ Fixnum
The location of the default configuration file.
-
.default_file=(file_path) ⇒ Object
Sets the location of the configuration YAML file and old deletes configurations.
-
.defaults ⇒ Hash
The default file loaded by yaml.
-
.delete(key) ⇒ Object
Remove the value of a config entry.
-
.delete_all ⇒ Object
Remove all configuration.
- .include_root_in_json ⇒ Object
- .module_handling ⇒ Object
-
.timestamp_type ⇒ Class
The configured timestamps type (e.g. Integer) or the default DateTime.
-
.to_hash ⇒ Hash
The config as a hash.
-
.to_yaml ⇒ String
The config as a YAML.
-
.use {|config| ... } ⇒ Object
Yields the configuration.
Class Method Details
.[](key) ⇒ Object
Returns the the value of a config entry.
70 71 72 |
# File 'lib/neo4j/config.rb', line 70 def [](key) configuration[key.to_s] end |
.[]=(key, val) ⇒ Object
Sets the value of a config entry.
64 65 66 |
# File 'lib/neo4j/config.rb', line 64 def []=(key, val) configuration[key.to_s] = val end |
.association_model_namespace ⇒ Object
113 114 115 |
# File 'lib/neo4j/config.rb', line 113 def association_model_namespace Neo4j::Config[:association_model_namespace] || nil end |
.association_model_namespace_string ⇒ Object
117 118 119 120 121 |
# File 'lib/neo4j/config.rb', line 117 def association_model_namespace_string namespace = Neo4j::Config[:association_model_namespace] return nil if namespace.nil? "::#{namespace}" end |
.configuration ⇒ Hash
Reads from the default_file if configuration is not set already
36 37 38 39 40 41 42 |
# File 'lib/neo4j/config.rb', line 36 def configuration return @configuration if @configuration @configuration = ActiveSupport::HashWithIndifferentAccess.new @configuration.merge!(defaults) @configuration end |
.default_file ⇒ Fixnum
Returns The location of the default configuration file.
16 17 18 |
# File 'lib/neo4j/config.rb', line 16 def default_file @default_file ||= DEFAULT_FILE end |
.default_file=(file_path) ⇒ Object
Sets the location of the configuration YAML file and old deletes configurations.
22 23 24 25 26 |
# File 'lib/neo4j/config.rb', line 22 def default_file=(file_path) delete_all @defaults = nil @default_file = File.(file_path) end |
.defaults ⇒ Hash
Returns the default file loaded by yaml.
29 30 31 32 |
# File 'lib/neo4j/config.rb', line 29 def defaults require 'yaml' @defaults ||= ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(default_file)) end |
.delete(key) ⇒ Object
Remove the value of a config entry.
78 79 80 |
# File 'lib/neo4j/config.rb', line 78 def delete(key) configuration.delete(key) end |
.delete_all ⇒ Object
Remove all configuration. This can be useful for testing purpose.
85 86 87 |
# File 'lib/neo4j/config.rb', line 85 def delete_all @configuration = nil end |
.include_root_in_json ⇒ Object
99 100 101 102 |
# File 'lib/neo4j/config.rb', line 99 def include_root_in_json # we use ternary because a simple || will always evaluate true Neo4j::Config[:include_root_in_json].nil? ? true : Neo4j::Config[:include_root_in_json] end |
.module_handling ⇒ Object
104 105 106 |
# File 'lib/neo4j/config.rb', line 104 def module_handling Neo4j::Config[:module_handling] || :none end |
.timestamp_type ⇒ Class
Returns The configured timestamps type (e.g. Integer) or the default DateTime.
109 110 111 |
# File 'lib/neo4j/config.rb', line 109 def Neo4j::Config[:timestamp_type] || DateTime end |
.to_hash ⇒ Hash
Returns The config as a hash.
90 91 92 |
# File 'lib/neo4j/config.rb', line 90 def to_hash configuration.to_hash end |
.to_yaml ⇒ String
Returns The config as a YAML.
95 96 97 |
# File 'lib/neo4j/config.rb', line 95 def to_yaml configuration.to_yaml end |
.use {|config| ... } ⇒ Object
Yields the configuration
54 55 56 57 58 |
# File 'lib/neo4j/config.rb', line 54 def use @configuration ||= ActiveSupport::HashWithIndifferentAccess.new yield @configuration nil end |