Sha256: 56aa970f7232f68663cad494d8e321cc813e0cb2b727cc9233e26d89887caa33

Contents?: true

Size: 638 Bytes

Versions: 4

Compression:

Stored size: 638 Bytes

Contents

module Euston
  class Command
    include ActiveModel::Validations

    def initialize body, dispatch_at = nil
      @headers = { :id => Uuid.generate,
                   :type => self.class.to_s.split('::').pop.underscore.to_sym }

      @body = body
      @headers[:dispatch_at] = dispatch_at unless dispatch_at.nil?
    end

    def headers
      @headers.merge :version => version
    end

    def id
      @headers[:id]
    end

    def read_attribute_for_validation key
      @body[key]
    end

    def to_hash
      { :headers => headers, :body => @body }
    end

    def version
      1
    end

    attr_reader :body
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
euston-1.2.1 lib/euston/command.rb
euston-1.2.1-java lib/euston/command.rb
euston-1.2.0 lib/euston/command.rb
euston-1.2.0-java lib/euston/command.rb