def update_from_hash(hash)
      j = self
      #update top line params
      j.update_attributes(:active => hash['active'],
                          :trigger => hash['trigger'])
      (1..5).to_a.each do |s_idx|
        stage_string = hash["stage#{s_idx.to_s}"]
        s = Stage.find_by_path("#{j.path}/stage#{s_idx.to_s}")
        if stage_string.to_s.length==0
          #delete this stage and all stages after
          if s
            j = s.job
            j.stages[(s.idx-1)..-1].each{|ps| ps.delete}
            #just in case
            s.delete
          end
          break
        elsif s.nil?
          #create this stage
          s = Stage.find_or_create_by_path("#{j.path}/stage#{s_idx.to_s}")
        end
        #parse command string, update stage with it
        s_handler, call, param_string = [""*3]
        stage_string.split(" ").ie do |spls|
          s_handler = spls.first.split(".").first
          call = spls.first.split(".").last
          param_string = spls[1..-1].join(" ").strip
        end
        s.update_attributes(:call=>call, :handler=>s_handler, :param_string=>param_string)
      end
      return j.reload
    end
def update_from_hash(hash)
      j = self
      #update top line params
      j.update_attributes(:active => hash['active'],
                          :trigger => hash['trigger'])
      (1..5).to_a.each do |s_idx|
        stage_string = hash["stage#{s_idx.to_s}"]
        s = Stage.find_by_path("#{j.path}/stage#{s_idx.to_s}")
        if stage_string.to_s.length==0
          #delete this stage and all stages after
          if s
            j = s.job
            j.stages[(s.idx-1)..-1].each{|ps| ps.delete}
            #just in case
            s.delete
          end
          break
        elsif s.nil?
          #create this stage
          s = Stage.find_or_create_by_path("#{j.path}/stage#{s_idx.to_s}")
        end
        #parse command string, update stage with it
        s_handler, call, param_string = [""*3]
        stage_string.split(" ").ie do |spls|
          s_handler = spls.first.split(".").first
          call = spls.first.split(".").last
          param_string = spls[1..-1].join(" ").strip
        end
        s.update_attributes(:call=>call, :handler=>s_handler, :param_string=>param_string)
      end
      return j.reload
    end
takes a hash of job parameters (name, active, trigger, stages)
and creates/updates a job with it