Class: EverSdk::Processing::ProcessingEvent
- Inherits:
-
Object
- Object
- EverSdk::Processing::ProcessingEvent
- Defined in:
- lib/ever_sdk_client/processing.rb
Constant Summary collapse
- TYPES =
%i[ will_fetch_first_block fetch_first_block_failed will_send did_send send_failed will_fetch_next_block fetch_next_block_failed message_expired remp_sent_to_validators remp_included_into_block remp_included_into_accepted_block remp_other remp_error ]
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#shard_block_id ⇒ Object
readonly
Returns the value of attribute shard_block_id.
-
#type_ ⇒ Object
readonly
Returns the value of attribute type_.
Instance Method Summary collapse
-
#initialize(type_:, error: nil, shard_block_id: nil, message_id: nil, message: nil, **args) ⇒ ProcessingEvent
constructor
A new instance of ProcessingEvent.
- #to_h ⇒ Object
Constructor Details
#initialize(type_:, error: nil, shard_block_id: nil, message_id: nil, message: nil, **args) ⇒ ProcessingEvent
Returns a new instance of ProcessingEvent.
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ever_sdk_client/processing.rb', line 105 def initialize(type_:, error: nil, shard_block_id: nil, message_id: nil, message: nil, **args) unless TYPES.include?(type_) raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPES}") end @type_ = type_ @error = error @shard_block_id = shard_block_id @message_id = @message = @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
103 104 105 |
# File 'lib/ever_sdk_client/processing.rb', line 103 def args @args end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
103 104 105 |
# File 'lib/ever_sdk_client/processing.rb', line 103 def error @error end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
103 104 105 |
# File 'lib/ever_sdk_client/processing.rb', line 103 def @message end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
103 104 105 |
# File 'lib/ever_sdk_client/processing.rb', line 103 def @message_id end |
#shard_block_id ⇒ Object (readonly)
Returns the value of attribute shard_block_id.
103 104 105 |
# File 'lib/ever_sdk_client/processing.rb', line 103 def shard_block_id @shard_block_id end |
#type_ ⇒ Object (readonly)
Returns the value of attribute type_.
103 104 105 |
# File 'lib/ever_sdk_client/processing.rb', line 103 def type_ @type_ end |
Instance Method Details
#to_h ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/ever_sdk_client/processing.rb', line 117 def to_h h1 = { type: @type } h2 = case @type_ when :will_fetch_first_block { } when :fetch_first_block_failed { error: @error } when :will_send, :did_send, :will_fetch_next_block { shard_block_id: @shard_block_id, message_id: @message_id, message: @message } when :send_failed, :fetch_next_block_failed { shard_block_id: @shard_block_id, message_id: @message_id, message: @message, error: @error } when :message_expired { message_id: @message_id, message: @message, error: @error } when :remp_sent_to_validators, :remp_included_into_block, :remp_included_into_accepted_block, :remp_other, :remp_error { message_id: , timestamp: args[:timestamp], json: args[:json] } else raise ArgumentError.new("unsupported type: #{@type_}") end h1.merge(h2) end |