Sha256: 29f8ac4a2c9445e069572b3c4b75f245ac06c9a9df46e003b4853d0a485b0b49

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 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

12 entries across 12 versions & 3 rubygems

Version Path
resurrected_god-0.14.0 lib/god/behavior.rb
mcproc-2016.2.20 lib/god/behavior.rb
god-0.13.7 lib/god/behavior.rb
god-0.13.6 lib/god/behavior.rb
god-0.13.5 lib/god/behavior.rb
god-0.13.4 lib/god/behavior.rb
god-0.13.3 lib/god/behavior.rb
god-0.13.2 lib/god/behavior.rb
god-0.13.1 lib/god/behavior.rb
god-0.13.0 lib/god/behavior.rb
god-0.12.1 lib/god/behavior.rb
god-0.12.0 lib/god/behavior.rb