Class: God::Behavior
- Inherits:
-
Object
show all
- Includes:
- Configurable
- Defined in:
- lib/god/behavior.rb
Instance Attribute Summary (collapse)
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
#base_name, complain, #complain, #prepare, #reset
Instance Attribute Details
- (Object) watch
Returns the value of attribute watch
6
7
8
|
# File 'lib/god/behavior.rb', line 6
def watch
@watch
end
|
Class Method Details
+ (Object) generate(kind, 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)
11
12
13
14
15
16
17
18
|
# File 'lib/god/behavior.rb', line 11
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
|
Instance Method Details
- (Object) after_restart
35
36
|
# File 'lib/god/behavior.rb', line 35
def after_restart
end
|
- (Object) after_start
29
30
|
# File 'lib/god/behavior.rb', line 29
def after_start
end
|
- (Object) after_stop
41
42
|
# File 'lib/god/behavior.rb', line 41
def after_stop
end
|
- (Object) before_restart
32
33
|
# File 'lib/god/behavior.rb', line 32
def before_restart
end
|
- (Object) before_start
26
27
|
# File 'lib/god/behavior.rb', line 26
def before_start
end
|
- (Object) before_stop
38
39
|
# File 'lib/god/behavior.rb', line 38
def before_stop
end
|
- (Object) friendly_name
Construct the friendly name of this Behavior, looks like:
Behavior FooBar on Watch 'baz'
47
48
49
|
# File 'lib/god/behavior.rb', line 47
def friendly_name
"Behavior " + super + " on Watch '#{self.watch.name}'"
end
|
- (Boolean) valid?
20
21
22
|
# File 'lib/god/behavior.rb', line 20
def valid?
true
end
|