Config¶
== Keeps configuration for neo4j
== Configurations keys
Constants¶
- DEFAULT_FILE
- CLASS_NAME_PROPERTY_KEY
Files¶
Methods¶
.[]
def [](key) configuration[key.to_s] end
- .[]=
Sets the value of a config entry.
def []=(key, val) configuration[key.to_s] = val end
.association_model_namespace
def association_model_namespace Neo4j::Config[:association_model_namespace] || nil end
.association_model_namespace_string
def association_model_namespace_string namespace = Neo4j::Config[:association_model_namespace] return nil if namespace.nil? "::#{namespace}" end
- .configuration
Reads from the default_file if configuration is not set already
def configuration return @configuration if @configuration @configuration = ActiveSupport::HashWithIndifferentAccess.new @configuration.merge!(defaults) @configuration end
.default_file
def default_file @default_file ||= DEFAULT_FILE end
- .default_file=
Sets the location of the configuration YAML file and old deletes configurations.
def default_file=(file_path) delete_all @defaults = nil @default_file = File.expand_path(file_path) end
.defaults
def defaults require 'yaml' @defaults ||= ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(default_file)) end
- .delete
Remove the value of a config entry.
def delete(key) configuration.delete(key) end
- .delete_all
Remove all configuration. This can be useful for testing purpose.
def delete_all @configuration = nil end
.include_root_in_json
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
def module_handling Neo4j::Config[:module_handling] || :none end
.timestamp_type
def timestamp_type Neo4j::Config[:timestamp_type] || DateTime end
.to_hash
def to_hash configuration.to_hash end
.to_yaml
def to_yaml configuration.to_yaml end
- .use
Yields the configuration
def use @configuration ||= ActiveSupport::HashWithIndifferentAccess.new yield @configuration nil end