Sha256: b5ae1be2f61ec0f5a76ac62966592ff94c3a8d070b8d31f7607ae6fd7cbf7427
Contents?: true
Size: 1.8 KB
Versions: 4
Compression:
Stored size: 1.8 KB
Contents
module God class Behavior attr_accessor :watch # Generate a Behavior of the given kind. The proper class if found by camel casing the # kind (which is given as an underscored symbol). # +kind+ is the underscored symbol representing the class (e.g. foo_bar for God::Behaviors::FooBar) def self.generate(kind, watch) sym = kind.to_s.capitalize.gsub(/_(.)/){$1.upcase}.intern b = God::Behaviors.const_get(sym).new b.watch = watch b rescue NameError raise NoSuchBehaviorError.new("No Behavior found with the class name God::Behaviors::#{sym}") end # Override this method in your Behaviors (optional) # # Called once after the Condition has been sent to the block and attributes have been # set. Do any post-processing on attributes here def prepare end # Override this method in your Behaviors (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 def valid? true end ####### def before_start end def after_start end def before_restart end def after_restart end def before_stop end def after_stop end protected def complain(text) Syslog.err(text) puts text false end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
god-0.3.0 | lib/god/behavior.rb |
god-0.4.0 | lib/god/behavior.rb |
god-0.4.1 | lib/god/behavior.rb |
god-0.4.3 | lib/god/behavior.rb |