Sha256: 05d88b737792d8502091a876f847fc5e5d0f57eac80c61d9b41f5f2b44870874

Contents?: true

Size: 473 Bytes

Versions: 15

Compression:

Stored size: 473 Bytes

Contents

module Telegram
  module Bot
    module Types
      class Base
        include Virtus.model

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

            [key, value]
          end]
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
telegram-bot-ruby-0.8.3 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.8.2 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.8.1 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.8.0 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.7.2 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.7.1 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.7.0 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.6.0.2 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.6.0.1 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.5.3 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.5.2 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.5.1 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.5.0 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.5.0.beta4 lib/telegram/bot/types/base.rb
telegram-bot-ruby-0.5.0.beta3 lib/telegram/bot/types/base.rb