Class: Architect4r::Core::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/architect4r/core/configuration.rb

Overview

Architect4r can be configured by creating a config/architect4r file and provide environment specific data.

Thanks to the sunspot-rails gem team, as this class is heavily inspired by their work!

development:
  host: localhost
  port: 7474
  log_level: DEBUG
test:
  host: localhost
  port: 7474
  log_level: OFF
production:
  host: localhost
  port: 8080
  path: /my_neo_instance
  log_level: WARNING

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



25
26
27
28
29
# File 'lib/architect4r/core/configuration.rb', line 25

def initialize(options = {})
  options ||= {}
  @environment = options.delete(:environment).to_s if options.has_key?(:environment)
  self.custom_configuration = options.delete(:config) if options.has_key?(:config)
end

Instance Method Details

#environmentObject



31
32
33
# File 'lib/architect4r/core/configuration.rb', line 31

def environment
  @environment ||= 'development'
end

#hostObject



35
36
37
38
39
40
41
42
# File 'lib/architect4r/core/configuration.rb', line 35

def host
  unless defined?(@hostname)
    @hostname   = neo4j_url.host if neo4j_url
    @hostname ||= custom_configuration_from_key('host')
    @hostname ||= default_hostname
  end
  @hostname
end

#log_fileObject



67
68
69
# File 'lib/architect4r/core/configuration.rb', line 67

def log_file
  @log_file ||= (custom_configuration_from_key('log_file') || default_log_file_location )
end

#log_levelObject



63
64
65
# File 'lib/architect4r/core/configuration.rb', line 63

def log_level
  @log_level ||= (custom_configuration_from_key('log_level') || default_log_level)
end

#pathObject



54
55
56
57
58
59
60
61
# File 'lib/architect4r/core/configuration.rb', line 54

def path
  unless defined?(@path)
    @path   = neo4j_url.path if neo4j_url
    @path ||= custom_configuration_from_key('path')
    @path ||= default_path
  end
  @path
end

#portObject



44
45
46
47
48
49
50
51
52
# File 'lib/architect4r/core/configuration.rb', line 44

def port
  unless defined?(@port)
    @port   = neo4j_url.port if neo4j_url
    @port ||= custom_configuration_from_key('port')
    @port ||= default_port
    @port   = @port.to_i
  end
  @port
end