# File lib/rconfig/reload.rb, line 65 65: def auto_check?(name) 66: now = Time.now 67: if (!self.last_auto_check[name]) || (now - self.last_auto_check[name]) > self.reload_interval 68: self.last_auto_check[name] = now 69: return true 70: end 71: return false 72: end
Sets the flag indicating whether or not reload should be executed.
# File lib/rconfig/reload.rb, line 16 16: def enable_reload=(reload) 17: raise ArgumentError, 'Argument must be true or false.' unless [true, false].include?(reload) 18: self.enable_reload = reload 19: end
Flushes cached config data, so that it can be reloaded from disk. It is recommended that this should be used with caution, and any need to reload in a production setting should minimized or completely avoided if possible.
# File lib/rconfig/reload.rb, line 36 36: def reload(force=false) 37: raise ArgumentError, 'Argument must be true or false.' unless [true, false].include?(force) 38: if force || reload? 39: flush_cache 40: return true 41: end 42: false 43: end
Flag indicating whether or not reload should be executed.
# File lib/rconfig/reload.rb, line 6 6: def reload? 7: self.enable_reload 8: end
# File lib/rconfig/reload.rb, line 10 10: def reload_disabled? 11: not reload? 12: end
Sets the number of seconds between reloading of config files and automatic reload checks. Defaults to 5 minutes. Setting
# File lib/rconfig/reload.rb, line 25 25: def reload_interval=(interval) 26: raise ArgumentError, 'Argument must be Integer.' unless interval.kind_of?(Integer) 27: self.enable_reload = false if interval == 0 # Sett 28: self.reload_interval = interval 29: end
Executes given block, without reloading any config. Meant to run configuration-sensitive code that may otherwise trigger a reload of any/all config files. If reload is disabled then it makes no difference if this wrapper is used or not. Returns result of the block
# File lib/rconfig/reload.rb, line 51 51: def without_reload(&block) 52: return unless block_given? 53: result = nil 54: enable_reload_cache = self.enable_reload 55: begin 56: self.enable_reload 57: result = yield 58: ensure 59: self.enable_reload = enable_reload_cache 60: check_config_changed if reload? 61: end 62: result 63: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.