Sha256: 0da21abb0062db32a85e4d3cd5403af37dd5ad02a44cf0762c48563c4468a1f9

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module LunchMoney
  # Base data object for the objects returned and used when calling the LunchMoney API
  class DataObject
    sig { params(symbolize_keys: T::Boolean).returns(T::Hash[String, T.untyped]) }
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lunchmoney-1.0.0 lib/lunchmoney/data_object.rb
lunchmoney-0.10.0 lib/lunchmoney/data_object.rb