Sha256: a50b3a34002dda54c64caaca37db1d8e1b53e7a8a24050c1c7f71e4285a4efd4
Contents?: true
Size: 878 Bytes
Versions: 3
Compression:
Stored size: 878 Bytes
Contents
# frozen_string_literal: true require 'telegram/bot/client/api_helper' require 'active_support/core_ext/string/inflections' module Telegram module Bot class Client # Actions with type-casted results. Install `telegram-bot-types` gem first. module TypedResponse # First we define methods for every available api method to return `result` # field instead of object. ApiHelper.methods_list.each do |method| define_method(method.to_s.underscore) do |*args| super(*args)['result'] end end # And then override some of them which has castable results. Types::Response::WRAPPED_METHODS.each do |method, type| define_method(method.to_s.underscore) do |*args| Types::Response.wrap(super(*args)['result'], type) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
telegram-bot-0.16.5 | lib/telegram/bot/client/typed_response.rb |
telegram-bot-0.16.4 | lib/telegram/bot/client/typed_response.rb |
telegram-bot-0.16.3 | lib/telegram/bot/client/typed_response.rb |