class ActiveGraph::Config
Keeps configuration for neo4j¶ ↑
Configurations keys¶ ↑
Constants
- 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/active_graph/config.rb 69 def [](key) 70 configuration[key.to_s] 71 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/active_graph/config.rb 63 def []=(key, val) 64 configuration[key.to_s] = val 65 end
# File lib/active_graph/config.rb 120 def association_model_namespace 121 ActiveGraph::Config[:association_model_namespace] || nil 122 end
# File lib/active_graph/config.rb 124 def association_model_namespace_string 125 namespace = ActiveGraph::Config[:association_model_namespace] 126 return nil if namespace.nil? 127 "::#{namespace}" 128 end
Reads from the default_file
if configuration is not set already @return [Hash] the configuration
# File lib/active_graph/config.rb 35 def configuration 36 return @configuration if @configuration 37 38 @configuration = ActiveSupport::HashWithIndifferentAccess.new 39 @configuration.merge!(defaults) 40 @configuration 41 end
@return [Integer] The location of the default configuration file.
# File lib/active_graph/config.rb 15 def default_file 16 @default_file ||= DEFAULT_FILE 17 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/active_graph/config.rb 21 def default_file=(file_path) 22 delete_all 23 @defaults = nil 24 @default_file = File.expand_path(file_path) 25 end
@return [Hash] the default file loaded by yaml
# File lib/active_graph/config.rb 28 def defaults 29 require 'yaml' 30 @defaults ||= ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(default_file)) 31 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/active_graph/config.rb 81 def delete(key) 82 configuration.delete(key) 83 end
Remove all configuration. This can be useful for testing purpose.
@return nil
# File lib/active_graph/config.rb 88 def delete_all 89 @configuration = nil 90 end
# File lib/active_graph/config.rb 130 def enums_case_sensitive 131 ActiveGraph::Config[:enums_case_sensitive] || false 132 end
# File lib/active_graph/config.rb 102 def fail_on_pending_migrations 103 ActiveGraph::Config[:fail_on_pending_migrations].nil? ? true : ActiveGraph::Config[:fail_on_pending_migrations] 104 end
# File lib/active_graph/config.rb 73 def fetch(key, default) 74 configuration.fetch(key, default) 75 end
# File lib/active_graph/config.rb 106 def include_root_in_json 107 # we use ternary because a simple || will always evaluate true 108 ActiveGraph::Config[:include_root_in_json].nil? ? true : ActiveGraph::Config[:include_root_in_json] 109 end
# File lib/active_graph/config.rb 111 def module_handling 112 ActiveGraph::Config[:module_handling] || :none 113 end
@return [Class] The configured timestamps type (e.g. Integer) or the default DateTime.
# File lib/active_graph/config.rb 116 def timestamp_type 117 ActiveGraph::Config[:timestamp_type] || DateTime 118 end
@return [Hash] The config as a hash.
# File lib/active_graph/config.rb 93 def to_hash 94 configuration.to_hash 95 end
@return [String] The config as a YAML
# File lib/active_graph/config.rb 98 def to_yaml 99 configuration.to_yaml 100 end
Yields the configuration
@example
ActiveGraph::Config.use do |config| config[:storage_path] = '/var/neo4j' end
@return nil @yield config @yieldparam [ActiveGraph::Config] config - this configuration class
# File lib/active_graph/config.rb 53 def use 54 @configuration ||= ActiveSupport::HashWithIndifferentAccess.new 55 yield @configuration 56 nil 57 end