Class: EventHub::Configuration

Inherits:
Object
  • Object
show all
Includes:
Helper, Singleton
Defined in:
lib/eventhub/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#class_to_array, #duration, #format_string, #get_host, #get_ip_adresses, #now_stamp

Constructor Details

#initializeConfiguration



9
10
11
12
13
# File 'lib/eventhub/configuration.rb', line 9

def initialize
  @data = nil
   @folder = Dir.pwd
   @environment = 'development'
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/eventhub/configuration.rb', line 7

def data
  @data
end

#environmentObject

Returns the value of attribute environment.



7
8
9
# File 'lib/eventhub/configuration.rb', line 7

def environment
  @environment
end

#folderObject

Returns the value of attribute folder.



7
8
9
# File 'lib/eventhub/configuration.rb', line 7

def folder
  @folder
end

Instance Method Details

#load_file(input, env = 'development') ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/eventhub/configuration.rb', line 15

def load_file(input, env='development')
  tmp = JSON.parse( IO.read(input))
@data = tmp[env]
  @environment = env
  true
rescue => e
  EventHub.logger.info("Unexpected exception while loading configuration [#{input}]: #{format_string(e.message)}")
 false
end