Method: BasecommSdk::Base#to_json

Defined in:
lib/basecomm_sdk/base.rb

#to_json(_options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/basecomm_sdk/base.rb', line 54

def to_json(_options = {})
  hash = {}
  instance_variables.each do |iv|
    var_name = iv.to_s[1..-1]
    next if var_name.match(/messages$/)
    var = instance_variable_get(iv)
    hash[qualified_key(var_name)] = format(var) unless var.nil?
  end
  hash.to_json
end