Class: GalacticSenate::Configuration
- Inherits:
-
Object
- Object
- GalacticSenate::Configuration
- Defined in:
- lib/galactic-senate/configuration.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #on(event, &block) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/galactic-senate/configuration.rb', line 8 def initialize @redis = nil @logger = Logger.new(STDOUT) @logger.level = Logger::WARN @events = { elected: [], ousted: [], supreme_chancellor_changed: [] } end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
6 7 8 |
# File 'lib/galactic-senate/configuration.rb', line 6 def events @events end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/galactic-senate/configuration.rb', line 6 def logger @logger end |
#redis ⇒ Object
Returns the value of attribute redis.
6 7 8 |
# File 'lib/galactic-senate/configuration.rb', line 6 def redis @redis end |
Instance Method Details
#on(event, &block) ⇒ Object
20 21 22 23 |
# File 'lib/galactic-senate/configuration.rb', line 20 def on(event, &block) raise ArgumentError, "Invalid event: #{event}" unless @events.key?(event) && event.is_a?(Symbol) @events[event] << block end |