# File lib/god/task.rb, line 72 def transition(start_states, end_states) # convert end_states into canonical hash form canonical_end_states = canonical_hash_form(end_states) Array(start_states).each do |start_state| # validate start state unless self.valid_states.include?(start_state) abort "Invalid state :#{start_state}. Must be one of the symbols #{self.valid_states.map{|x| ":#{x}"}.join(', ')}" end # create a new metric to hold the watch, end states, and conditions m = Metric.new(self, canonical_end_states) if block_given? # let the config file define some conditions on the metric yield(m) else # add an :always condition if no block m.condition(:always) do |c| c.what = true end end # record the metric self.metrics[start_state] ||= [] self.metrics[start_state] << m end end