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, #now_stamp

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

def initialize
  @data = nil
  @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



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

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