Sha256: 04155168f08a69d2d5bae80d367c02bb07742be76fba78d70fbdf45154c2abc4

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

require 'active_support/concern'
require 'simple_states'

class Job
  class Configure
    module States
      extend ActiveSupport::Concern

      included do
        include SimpleStates, Job::States, Travis::Notifications

        states :created, :started, :finished

        event :start,  :to => :started,  :after => :propagate
        event :finish, :to => :finished, :after => :configure_owner # TODO why not just propagate here?
        event :all, :after => :notify

        after_create do
          notify(:create)
        end

        def finish(data)
          [:config, :status, :finished_at].each do |key|
            send(:"#{key}=", data[key]) if data.key?(key)
          end
        end

        def configure_owner(event, data)
          owner.configure!(data)
        end

        protected

          def extract_finishing_attributes(attributes)
            extract!(attributes, :config)
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-core-0.0.1 lib/travis/model/job/configure/states.rb