Module: TimedConfig
- Defined in:
- lib/timed_config.rb,
lib/timed_config/gems.rb
Defined Under Namespace
Modules: Gems
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/timed_config.rb', line 6 def config @config end |
Class Method Details
.path ⇒ Object
8 9 10 |
# File 'lib/timed_config.rb', line 8 def path @path || (defined?(Rails) ? "#{Rails.root}/config/timed_config.yml" : nil) end |
.path=(p) ⇒ Object
12 13 14 15 16 |
# File 'lib/timed_config.rb', line 12 def path=(p) thread.stop rescue nil @path = p thread.run end |
.period ⇒ Object
18 19 20 |
# File 'lib/timed_config.rb', line 18 def period @period || 60 end |
.period=(seconds) ⇒ Object
22 23 24 25 26 |
# File 'lib/timed_config.rb', line 22 def period=(seconds) thread.stop rescue nil @period = seconds thread.run end |
.thread ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/timed_config.rb', line 28 def thread @thread ||= Thread.new do while true if TimedConfig.path && File.exists?(TimedConfig.path) TimedConfig.config = YAML::load(File.open(TimedConfig.path)) end sleep TimedConfig.period end end end |