aboutsummaryrefslogblamecommitdiffstats
path: root/actioncable/lib/action_cable/engine.rb
blob: 071dcd73e47e76671c1ec5fd3174fda127b43fbc (plain) (tree)
1
2
3
4
5
6
7
8
9
                      
                      
                                        
                                                  
 

                                

                                                           



                                                       

       












                                                                                             

     
require 'rails/engine'
require 'action_cable'
require 'active_support/ordered_options'
require 'action_cable/helpers/action_cable_helper'

module ActionCable
  class Engine < ::Rails::Engine
    config.action_cable = ActiveSupport::OrderedOptions.new

    initializer "action_cable.helpers" do
      ActiveSupport.on_load(:action_view) do
        include ActionCable::Helpers::ActionCableHelper
      end
    end

    initializer "action_cable.logger" do
      ActiveSupport.on_load(:action_cable) { self.logger ||= ::Rails.logger }
    end

    initializer "action_cable.set_configs" do |app|
      options = app.config.action_cable

      options.allowed_request_origins ||= "http://localhost:3000" if ::Rails.env.development?

      ActiveSupport.on_load(:action_cable) do
        options.each { |k,v| send("#{k}=", v) }
      end
    end
  end
end