Class: FireflyServer::Configuration
- Inherits:
-
Object
- Object
- FireflyServer::Configuration
- Defined in:
- lib/firefly_server/configuration.rb
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #on_change(&block) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Configuration
Returns a new instance of Configuration.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/firefly_server/configuration.rb', line 17 def initialize(params = {}) # defaults self.restart_attempt_throttle_threshold = 3 self.restart_attempt_throttle_sleep = 3 self.exit_signals = %w[ SIGINT ] # watcher defaults self.watch_paths = [] self.ignore_paths = [] self.file_change_callbacks = [] # override defaults params.each do |key, value| send("#{key}=", value) end end |
Instance Method Details
#on_change(&block) ⇒ Object
36 37 38 39 |
# File 'lib/firefly_server/configuration.rb', line 36 def on_change(&block) file_change_callbacks << block if block self end |
#validate! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/firefly_server/configuration.rb', line 41 def validate! # validate require options set %w[ start_server stop_server pid_file ].each do |attribute| if !send(attribute) raise(ArgumentError, "#{attribute} option must be provided") end end if watch_paths.empty? raise(ArgumentError, "watch_paths option must be provided") end self end |