Sha256: 9ca490be9741c0e8b8b527be8fab88db04396292b7775190f1bd475aa3df5acc

Contents?: true

Size: 1.1 KB

Versions: 69

Compression:

Stored size: 1.1 KB

Contents

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(/_(.)/){$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
    
    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 '#{self.watch.name}'"
    end
  end
  
end

Version data entries

69 entries across 69 versions & 21 rubygems

Version Path
dguettler-god-0.7.13.2 lib/god/behavior.rb
dguettler-god-0.7.13.3 lib/god/behavior.rb
dosire-god-0.7.10 lib/god/behavior.rb
dosire-god-0.7.12 lib/god/behavior.rb
dosire-god-0.7.9 lib/god/behavior.rb
dunedain289-god-0.7.12.1 lib/god/behavior.rb
dustin-god-0.7.7.1 lib/god/behavior.rb
eric-god-0.7.10 lib/god/behavior.rb
eric-god-0.7.11 lib/god/behavior.rb
eric-god-0.7.12 lib/god/behavior.rb
eric-god-0.7.14 lib/god/behavior.rb
eric-god-0.7.7 lib/god/behavior.rb
fotonauts-god-0.7.10 lib/god/behavior.rb
fotonauts-god-0.7.12 lib/god/behavior.rb
gohanlonllc-god-0.7.9 lib/god/behavior.rb
gordoncww-god-0.7.11.1 lib/god/behavior.rb
jreynolds-god-0.7.13 lib/god/behavior.rb
jwilkins-god-0.7.9 lib/god/behavior.rb
mathieuravaux-god-0.7.11 lib/god/behavior.rb
mojombo-god-0.7.10 lib/god/behavior.rb