Module: God::Configurable
Class Method Summary collapse
Instance Method Summary collapse
- #base_name ⇒ Object
- #complain(text, c = nil) ⇒ Object
- #friendly_name ⇒ Object
-
#prepare ⇒ Object
Override this method in your Configurable (optional).
- #reset ⇒ Object
-
#valid? ⇒ Boolean
Override this method in your Configurable (optional).
Class Method Details
.complain(text, c = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/god/configurable.rb', line 42 def self.complain(text, c = nil) watch = c.watch rescue nil msg = "" msg += "#{watch.name}: " if watch msg += text msg += " for #{c.friendly_name}" if c applog(watch, :error, msg) false end |
Instance Method Details
#base_name ⇒ Object
33 34 35 36 |
# File 'lib/god/configurable.rb', line 33 def base_name x = 1 # fix for MRI's local scope optimization bug DO NOT REMOVE! @base_name ||= self.class.name.split('::').last end |
#complain(text, c = nil) ⇒ Object
52 53 54 |
# File 'lib/god/configurable.rb', line 52 def complain(text, c = nil) Configurable.complain(text, c) end |
#friendly_name ⇒ Object
38 39 40 |
# File 'lib/god/configurable.rb', line 38 def friendly_name base_name end |
#prepare ⇒ Object
Override this method in your Configurable (optional)
Called once after the Configurable has been sent to the block and attributes have been set. Do any post-processing on attributes here
8 9 10 |
# File 'lib/god/configurable.rb', line 8 def prepare end |
#reset ⇒ Object
12 13 14 |
# File 'lib/god/configurable.rb', line 12 def reset end |
#valid? ⇒ Boolean
Override this method in your Configurable (optional)
Called once during evaluation of the config file. Return true if valid, false otherwise
A convenience method ‘complain’ is available that will print out a message and return false, making it easy to report multiple validation errors:
def valid?
valid = true
valid &= complain("You must specify the 'pid_file' attribute for :memory_usage") if self.pid_file.nil?
valid &= complain("You must specify the 'above' attribute for :memory_usage") if self.above.nil?
valid
end
29 30 31 |
# File 'lib/god/configurable.rb', line 29 def valid? true end |