Class: LunchMoney::Objects::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/lunchmoney/objects/object.rb

Overview

Base data object for the objects returned and used when calling the LunchMoney API

Instance Method Summary collapse

Instance Method Details

#serialize(symbolize_keys: false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lunchmoney/objects/object.rb', line 10

def serialize(symbolize_keys: false)
  ivars = instance_variables

  output = {}

  ivars.each do |ivar|
    key = ivar.to_s.gsub("@", "")
    key = key.to_sym if symbolize_keys

    value = instance_variable_get(ivar)

    output[key] = value
  end

  output
end