Class: Candelabra::Configuration
- Inherits:
-
Object
- Object
- Candelabra::Configuration
- Includes:
- Singleton
- Defined in:
- lib/candelabra/configuration.rb
Instance Attribute Summary collapse
-
#auto_restart ⇒ Object
Returns the value of attribute auto_restart.
-
#event_handler ⇒ Object
Returns the value of attribute event_handler.
-
#in_installer ⇒ Object
Returns the value of attribute in_installer.
-
#on_error ⇒ Object
writeonly
Sets the attribute on_error.
-
#on_song_finish ⇒ Object
writeonly
Sets the attribute on_song_finish.
-
#on_song_start ⇒ Object
writeonly
Sets the attribute on_song_start.
Class Method Summary collapse
-
.clear ⇒ Object
Clear out the old settings in the configuration.
-
.go {|self.instance| ... } ⇒ Object
Initilize the configuration.
Instance Method Summary collapse
-
#call_event(event) ⇒ Object
Call the event requested by the system.
-
#handler? ⇒ Boolean
Check to determine if the hander has been set yet or not.
-
#method_missing(method, *args) ⇒ Object
short cut way of calling the system.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
short cut way of calling the system
41 42 43 44 45 46 47 |
# File 'lib/candelabra/configuration.rb', line 41 def method_missing( method, *args ) if method.to_s =~ /on_/ call_event( method ) else super method, *args end end |
Instance Attribute Details
#auto_restart ⇒ Object
Returns the value of attribute auto_restart.
5 6 7 |
# File 'lib/candelabra/configuration.rb', line 5 def auto_restart @auto_restart end |
#event_handler ⇒ Object
Returns the value of attribute event_handler.
5 6 7 |
# File 'lib/candelabra/configuration.rb', line 5 def event_handler @event_handler end |
#in_installer ⇒ Object
Returns the value of attribute in_installer.
5 6 7 |
# File 'lib/candelabra/configuration.rb', line 5 def in_installer @in_installer end |
#on_error=(value) ⇒ Object (writeonly)
Sets the attribute on_error
6 7 8 |
# File 'lib/candelabra/configuration.rb', line 6 def on_error=(value) @on_error = value end |
#on_song_finish=(value) ⇒ Object (writeonly)
Sets the attribute on_song_finish
6 7 8 |
# File 'lib/candelabra/configuration.rb', line 6 def on_song_finish=(value) @on_song_finish = value end |
#on_song_start=(value) ⇒ Object (writeonly)
Sets the attribute on_song_start
6 7 8 |
# File 'lib/candelabra/configuration.rb', line 6 def on_song_start=(value) @on_song_start = value end |
Class Method Details
.clear ⇒ Object
Clear out the old settings in the configuration
16 17 18 19 |
# File 'lib/candelabra/configuration.rb', line 16 def clear auto_restart, event_handler = nil,nil @on_song_start, @on_song_finish, @on_error = nil,nil,nil end |
.go {|self.instance| ... } ⇒ Object
Initilize the configuration
10 11 12 13 |
# File 'lib/candelabra/configuration.rb', line 10 def go clear yield self.instance end |
Instance Method Details
#call_event(event) ⇒ Object
Call the event requested by the system
Returns what ever the system is configured to or nil
30 31 32 33 34 35 36 37 38 |
# File 'lib/candelabra/configuration.rb', line 30 def call_event( event ) if handler? event_handler.send( event ) elsif instance_variable_get( "@" + event.to_s ).respond_to?( 'call' ) instance_variable_get( "@" + event.to_s ).send( :call ) else instance_variable_get( "@" + event.to_s ) end end |
#handler? ⇒ Boolean
Check to determine if the hander has been set yet or not
23 24 25 |
# File 'lib/candelabra/configuration.rb', line 23 def handler? !event_handler.nil? end |