Class: God::Conditions::Lambda

Inherits:
PollCondition show all
Includes:
ConditionHelper
Defined in:
lib/god/conditions/lambda.rb

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 included from ConditionHelper

#timeline_test

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, #reset

Constructor Details

#initializeLambda

Returns a new instance of Lambda.



8
9
10
11
# File 'lib/god/conditions/lambda.rb', line 8

def initialize
  super
  self.times = [1, 1]
end

Instance Attribute Details

#lambdaObject

Returns the value of attribute lambda.



6
7
8
# File 'lib/god/conditions/lambda.rb', line 6

def lambda
  @lambda
end

#timesObject

Returns the value of attribute times.



6
7
8
# File 'lib/god/conditions/lambda.rb', line 6

def times
  @times
end

Instance Method Details

#prepareObject



13
14
15
16
17
18
# File 'lib/god/conditions/lambda.rb', line 13

def prepare
  if self.times.kind_of?(Integer)
    self.times = [self.times, self.times]
  end
  @timeline = Timeline.new(self.times[1])
end

#testObject



26
27
28
# File 'lib/god/conditions/lambda.rb', line 26

def test  
  return timeline_test(self.lambda.call)
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/god/conditions/lambda.rb', line 20

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