Sha256: 9c345bbcc504443d05465f4c31c9d929b599bcb26c17bdd4ebd2b6496eb7ecda

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'telegram/bot/routes_helper'

module Telegram
  module Bot
    class Railtie < Rails::Railtie
      config.telegram_updates_controller = ActiveSupport::OrderedOptions.new

      rake_tasks do
        load 'tasks/telegram-bot.rake'
      end

      config.before_initialize do
        ::ActionDispatch::Routing::Mapper.include RoutesHelper
      end

      initializer 'telegram.bot.updates_controller.set_config' do |app|
        options = app.config.telegram_updates_controller

        ActiveSupport.on_load('telegram.bot.updates_controller') do
          self.logger = options.logger || Rails.logger
          self.session_store = options.session_store if options.session_store
        end
      end

      initializer 'telegram.bot.updates_controller.add_ar_runtime' do
        ActiveSupport.on_load('telegram.bot.updates_controller') do
          if defined?(ActiveRecord::Railties::ControllerRuntime)
            prepend ActiveRecord::Railties::ControllerRuntime
            extend ActiveRecord::Railties::ControllerRuntime::ClassMethods
          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/railtie.rb
telegram-bot-0.16.4 lib/telegram/bot/railtie.rb
telegram-bot-0.16.3 lib/telegram/bot/railtie.rb