Parent

Files

Class/Module Index [+]

Quicksearch

God::Condition

Attributes

info[RW]
notify[RW]
phase[RW]
transition[RW]

Public Class Methods

generate(kind, watch) click to toggle source

Generate a Condition of the given kind. The proper class if 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::Conditions::FooBar)
# File lib/god/condition.rb, line 9
def self.generate(kind, watch)
  sym = kind.to_s.capitalize.gsub(/_(.)/){$1.upcase}.intern
  c = God::Conditions.const_get(sym).new

  unless c.kind_of?(PollCondition) || c.kind_of?(EventCondition) || c.kind_of?(TriggerCondition)
    abort "Condition '#{c.class.name}' must subclass God::PollCondition, God::EventCondition, or God::TriggerCondition"
  end

  if !EventHandler.loaded? && c.kind_of?(EventCondition)
    abort "Condition '#{c.class.name}' requires an event system but none has been loaded"
  end

  c.watch = watch
  c
rescue NameError
  raise NoSuchConditionError.new("No Condition found with the class name God::Conditions::#{sym}")
end
valid?(condition) click to toggle source
# File lib/god/condition.rb, line 27
def self.valid?(condition)
  valid = true
  if condition.notify
    begin
      Contact.normalize(condition.notify)
    rescue ArgumentError => e
      valid &= Configurable.complain("Attribute 'notify' " + e.message, condition)
    end
  end
  valid
end

Public Instance Methods

friendly_name() click to toggle source

Construct the friendly name of this Condition, looks like:

Condition FooBar on Watch 'baz'

# File lib/god/condition.rb, line 42
def friendly_name
  "Condition #{self.class.name.split('::').last} on Watch '#{self.watch.name}'"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.