1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-05 02:35:50 +03:00

Ability to use type-castion with telegram-bot-types

Этот коммит содержится в:
Max Melentiev
2016-02-23 14:11:55 +06:00
родитель 00a2e3ba8d
Коммит a1adf17df3
24 изменённых файлов: 392 добавлений и 200 удалений

Просмотреть файл

@@ -1,5 +1,5 @@
module Telegram
class Bot
module Bot
class UpdatesController
# Most methods are taken from ActionController::Instrumentation,
# some are slightly modified.

Просмотреть файл

@@ -1,7 +1,7 @@
require 'active_support/log_subscriber'
module Telegram
class Bot
module Bot
class UpdatesController
class LogSubscriber < ActiveSupport::LogSubscriber
def start_processing(event)

Просмотреть файл

@@ -0,0 +1,8 @@
RSpec.shared_context 'telegram/bot/updates_controller' do
let(:instance) { described_class.new(bot, update) }
let(:update) { {payload_type => payload} }
let(:payload_type) { 'some_type' }
let(:payload) { double(:payload) }
let(:bot) { double(username: bot_name) }
let(:bot_name) { 'bot' }
end

Просмотреть файл

@@ -0,0 +1,14 @@
module Telegram
module Bot
class UpdatesController
# Include this module to type cast update to Virtus model
# using `telegram-bot-types` gem (install this gem first).
module TypedUpdate
def initialize(bot, update)
update = Types::Update.new(update) if update && !update.is_a?(Types::Update)
super
end
end
end
end
end