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