Class: Telegrambot::Types::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/telegrambot/types/base.rb

Instance Method Summary collapse

Instance Method Details

#to_compact_hashHash

Returns:

  • (Hash)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/telegrambot/types/base.rb', line 6

def to_compact_hash
  Hash[attributes.dup.delete_if { |_, v| v.nil? }.map do |key, value|
        value =
          if value.class.ancestors.include?(Telegrambot::Types::Base)
            value.to_compact_hash
          else
            value
          end
        [key, value]
  end]
end