Sha256: 8185e20331ecc4c13320fc00778675b9c26312910bcab3d30de1f673c509ca43
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module God class Behavior include Configurable attr_accessor :watch # Generate a Behavior of the given kind. The proper class is 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(/_(.)/) { Regexp.last_match(1).upcase }.intern b = God::Behaviors.const_get(sym).new b.watch = watch b rescue NameError raise NoSuchBehaviorError, "No Behavior found with the class name God::Behaviors::#{sym}" 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 # Construct the friendly name of this Behavior, looks like: # # Behavior FooBar on Watch 'baz' def friendly_name "Behavior #{super} on Watch '#{watch.name}'" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
resurrected_god-1.1.1 | lib/god/behavior.rb |
resurrected_god-1.1.0 | lib/god/behavior.rb |