Sha256: 7788d30a6c77b98a042e7f0b0a9b82e98d0d0d0659ba15217438ee4060c73921

Contents?: true

Size: 446 Bytes

Versions: 2

Compression:

Stored size: 446 Bytes

Contents

# frozen_string_literal: true

module Telegram
  module Bot
    module Types
      module Compactable
        def to_compact_hash
          attributes.dup.compact.to_h do |key, value|
            value = value.to_compact_hash if value.respond_to?(:to_compact_hash)

            [key, value]
          end
        end

        def to_json(*args)
          to_compact_hash.select { |_, v| v }.to_json(*args)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telegram-bot-ruby-2.1.0 lib/telegram/bot/types/compactable.rb
telegram-bot-ruby-2.0.0 lib/telegram/bot/types/compactable.rb