Class: EventHub::Configuration
- Inherits:
-
Object
- Object
- EventHub::Configuration
- Includes:
- Helper, Singleton
- Defined in:
- lib/eventhub/configuration.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#folder ⇒ Object
Returns the value of attribute folder.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_file(input, env = 'development') ⇒ Object
Methods included from Helper
#class_to_array, #duration, #format_string, #now_stamp
Constructor Details
#initialize ⇒ Configuration
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
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/eventhub/configuration.rb', line 7 def data @data end |
#environment ⇒ Object
Returns the value of attribute environment.
7 8 9 |
# File 'lib/eventhub/configuration.rb', line 7 def environment @environment end |
#folder ⇒ Object
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.)}") false end |