Method: Steem::Marshal#operations

Defined in:
lib/steem/marshal.rb

#operationsObject



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/steem/marshal.rb', line 197

def operations
  operations_len = signed_char
  operations = []
  
  while operations.size < operations_len do
    begin
      type = operation_type
      break if type.nil?
      
      op_class_name = type.to_s.sub!(/_operation$/, '')
      op_class_name = "Steem::Operation::" + op_class_name.split('_').map(&:capitalize).join
      op_class = Object::const_get(op_class_name)
      op = op_class.new
      
      op_class::serializable_types.each do |k, v|
        begin
          # binding.pry if v == :comment_options_extensions
          op.send("#{k}=", send(v))
        rescue => e
          raise DeserializationError.new("#{type}.#{k} (#{v}) failed", e)
        end
      end
      
      operations << {type: type, value: op}
    rescue => e
      raise DeserializationError.new("#{type} failed", e)
    end
  end
  
  operations
rescue => e
  raise DeserializationError.new("Operations failed", e)
end