Sha256: bb28389abe76c3335fd42b2103c7189f9c0af0ae802bfcae6637f6f22e6ae31c

Contents?: true

Size: 703 Bytes

Versions: 5

Compression:

Stored size: 703 Bytes

Contents

require 'json'
module Tamashii
  module Agent
    class RequestPool
      class Request
        attr_accessor :id
        attr_accessor :ev_type
        attr_accessor :ev_body
        attr_accessor :state

        STATE_PENDING = :pending
        STATE_SENT = :sent

        def initialize(ev_type, ev_body, id)
          @ev_type = ev_type
          @ev_body = ev_body
          @id = id
          @state = STATE_PENDING
        end

        def wrap_body
          {
            id: @id,
            ev_body: @ev_body
          }.to_json
        end

        def sent!
          @state = STATE_SENT
        end

        def sent?
          @state == STATE_SENT
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tamashii-agent-0.1.11 lib/tamashii/agent/request_pool/request.rb
tamashii-agent-0.1.10 lib/tamashii/agent/request_pool/request.rb
tamashii-agent-0.1.9 lib/tamashii/agent/request_pool/request.rb
tamashii-agent-0.1.8 lib/tamashii/agent/request_pool/request.rb
tamashii-agent-0.1.7 lib/tamashii/agent/request_pool/request.rb