Behavior
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
# 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
Generated with the Darkfish Rdoc Generator 2.