Class: God::Conditions::Always

Inherits:
PollCondition show all
Defined in:
lib/god/conditions/always.rb

Overview

Always trigger or never trigger.

Examples

# Always trigger.
on.condition(:always) do |c|
  c.what = true
end

# Never trigger.
on.condition(:always) do |c|
  c.what = false
end

Instance Attribute Summary collapse

Attributes inherited from PollCondition

#interval

Attributes inherited from God::Condition

#info, #notify, #phase, #transition

Attributes inherited from Behavior

#watch

Instance Method Summary collapse

Methods inherited from PollCondition

#after, #before

Methods inherited from God::Condition

#friendly_name, generate, valid?

Methods inherited from Behavior

#after_restart, #after_start, #after_stop, #before_restart, #before_start, #before_stop, #friendly_name, generate

Methods included from God::Configurable

#base_name, complain, #complain, #friendly_name, #prepare, #reset

Constructor Details

#initializeAlways

Returns a new instance of Always.



21
22
23
# File 'lib/god/conditions/always.rb', line 21

def initialize
  self.info = "always"
end

Instance Attribute Details

#whatObject

The Boolean determining whether this condition will always trigger (true) or never trigger (false).



19
20
21
# File 'lib/god/conditions/always.rb', line 19

def what
  @what
end

Instance Method Details

#testObject



31
32
33
# File 'lib/god/conditions/always.rb', line 31

def test
  @what
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/god/conditions/always.rb', line 25

def valid?
  valid = true
  valid &= complain("Attribute 'what' must be specified", self) if self.what.nil?
  valid
end