Class: ActiveGraph::Config
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveGraph::Config
 
 
- Defined in:
 - lib/active_graph/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 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  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    
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.
 - .enums_case_sensitive ⇒ Object
 - .fail_on_pending_migrations ⇒ Object
 - .fetch(key, default) ⇒ Object
 - .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.
      68 69 70  | 
    
      # File 'lib/active_graph/config.rb', line 68 def [](key) configuration[key.to_s] end  | 
  
.[]=(key, val) ⇒ Object
Sets the value of a config entry.
      62 63 64  | 
    
      # File 'lib/active_graph/config.rb', line 62 def []=(key, val) configuration[key.to_s] = val end  | 
  
.association_model_namespace ⇒ Object
      119 120 121  | 
    
      # File 'lib/active_graph/config.rb', line 119 def association_model_namespace ActiveGraph::Config[:association_model_namespace] || nil end  | 
  
.association_model_namespace_string ⇒ Object
      123 124 125 126 127  | 
    
      # File 'lib/active_graph/config.rb', line 123 def association_model_namespace_string namespace = ActiveGraph::Config[:association_model_namespace] return nil if namespace.nil? "::#{namespace}" end  | 
  
.configuration ⇒ Hash
Reads from the default_file if configuration is not set already
      34 35 36 37 38 39 40  | 
    
      # File 'lib/active_graph/config.rb', line 34 def configuration return @configuration if @configuration @configuration = ActiveSupport::HashWithIndifferentAccess.new @configuration.merge!(defaults) @configuration end  | 
  
.default_file ⇒ Integer
Returns The location of the default configuration file.
      15 16 17  | 
    
      # File 'lib/active_graph/config.rb', line 15 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.
      21 22 23 24 25  | 
    
      # File 'lib/active_graph/config.rb', line 21 def default_file=(file_path) delete_all @defaults = nil @default_file = File.(file_path) end  | 
  
.defaults ⇒ Hash
Returns the default file loaded by yaml.
      28 29 30  | 
    
      # File 'lib/active_graph/config.rb', line 28 def defaults @defaults ||= ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(default_file)) end  | 
  
.delete(key) ⇒ Object
Remove the value of a config entry.
      80 81 82  | 
    
      # File 'lib/active_graph/config.rb', line 80 def delete(key) configuration.delete(key) end  | 
  
.delete_all ⇒ Object
Remove all configuration. This can be useful for testing purpose.
      87 88 89  | 
    
      # File 'lib/active_graph/config.rb', line 87 def delete_all @configuration = nil end  | 
  
.enums_case_sensitive ⇒ Object
      129 130 131  | 
    
      # File 'lib/active_graph/config.rb', line 129 def enums_case_sensitive ActiveGraph::Config[:enums_case_sensitive] || false end  | 
  
.fail_on_pending_migrations ⇒ Object
      101 102 103  | 
    
      # File 'lib/active_graph/config.rb', line 101 def fail_on_pending_migrations ActiveGraph::Config[:fail_on_pending_migrations].nil? ? true : ActiveGraph::Config[:fail_on_pending_migrations] end  | 
  
.fetch(key, default) ⇒ Object
      72 73 74  | 
    
      # File 'lib/active_graph/config.rb', line 72 def fetch(key, default) configuration.fetch(key, default) end  | 
  
.include_root_in_json ⇒ Object
      105 106 107 108  | 
    
      # File 'lib/active_graph/config.rb', line 105 def include_root_in_json # we use ternary because a simple || will always evaluate true ActiveGraph::Config[:include_root_in_json].nil? ? true : ActiveGraph::Config[:include_root_in_json] end  | 
  
.module_handling ⇒ Object
      110 111 112  | 
    
      # File 'lib/active_graph/config.rb', line 110 def module_handling ActiveGraph::Config[:module_handling] || :none end  | 
  
.timestamp_type ⇒ Class
Returns The configured timestamps type (e.g. Integer) or the default DateTime.
      115 116 117  | 
    
      # File 'lib/active_graph/config.rb', line 115 def ActiveGraph::Config[:timestamp_type] || DateTime end  | 
  
.to_hash ⇒ Hash
Returns The config as a hash.
      92 93 94  | 
    
      # File 'lib/active_graph/config.rb', line 92 def to_hash configuration.to_hash end  | 
  
.to_yaml ⇒ String
Returns The config as a YAML.
      97 98 99  | 
    
      # File 'lib/active_graph/config.rb', line 97 def to_yaml configuration.to_yaml end  | 
  
.use {|config| ... } ⇒ Object
Yields the configuration
      52 53 54 55 56  | 
    
      # File 'lib/active_graph/config.rb', line 52 def use @configuration ||= ActiveSupport::HashWithIndifferentAccess.new yield @configuration nil end  |