Class: Icss::Message

Inherits:
Object
  • Object
show all
Includes:
Receiver, Receiver::ActsAsHash
Defined in:
lib/icss/message.rb,
lib/icss/sample_message_call.rb

Overview

Describes an Avro Message

A message has attributes:

  • doc: an optional description of the message,

  • request: a list of named, typed parameter schemas (this has the same form as the fields of a record declaration);

  • response: a valid schema for the response

  • errors: an optional union of error schemas.

A request parameter list is processed equivalently to an anonymous record. Since record field lists may vary between reader and writer, request parameters may also differ between the caller and responder, and such differences are resolved in the same manner as record field differences.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#protocolObject

Returns the value of attribute protocol.



31
32
33
# File 'lib/icss/message.rb', line 31

def protocol
  @protocol
end

Instance Method Details

#first_sample_request_paramObject



46
47
48
49
# File 'lib/icss/message.rb', line 46

def first_sample_request_param
  req = samples.first.request.first rescue nil
  req || {}
end

#pathObject



42
43
44
# File 'lib/icss/message.rb', line 42

def path
  File.join(protocol.path, name)
end

#to_hashObject

Conversion



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/icss/message.rb', line 54

def to_hash()
  {
    :doc      => doc,
    :initial_free_qty => initial_free_qty,
    :price_per_k_in_cents => price_per_k_in_cents,
    :request  => summary_of_request_attr,
    :response => summary_of_response_attr,
    :samples  => samples.map(&:to_hash).map(&:compact_blank),
    :errors   => (errors.blank? ? nil : errors),
  }.reject{|k,v| v.nil? }
end

#to_json(*args) ⇒ Object



65
# File 'lib/icss/message.rb', line 65

def to_json(*args) to_hash.to_json(*args) ; end