aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/engine.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-12-14 15:48:54 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-12-14 15:48:54 +0100
commitbf40bddfceebaff637161be6c5d992d6978679ff (patch)
treeb3541d5ec5015ab9459d1970a9f10fd37c0156c3 /actioncable/lib/action_cable/engine.rb
parent4073a3e3fe77141d09ed767224a1089796de2f7d (diff)
downloadrails-bf40bddfceebaff637161be6c5d992d6978679ff.tar.gz
rails-bf40bddfceebaff637161be6c5d992d6978679ff.tar.bz2
rails-bf40bddfceebaff637161be6c5d992d6978679ff.zip
Get ready to merge into Rails
Diffstat (limited to 'actioncable/lib/action_cable/engine.rb')
-rw-r--r--actioncable/lib/action_cable/engine.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/actioncable/lib/action_cable/engine.rb b/actioncable/lib/action_cable/engine.rb
new file mode 100644
index 0000000000..4777c3886b
--- /dev/null
+++ b/actioncable/lib/action_cable/engine.rb
@@ -0,0 +1,27 @@
+require 'rails/engine'
+require 'active_support/ordered_options'
+require 'action_cable/helpers/action_cable_helper'
+
+module ActionCable
+ class Engine < ::Rails::Engine
+ config.action_cable = ActiveSupport::OrderedOptions.new
+
+ config.to_prepare do
+ ApplicationController.helper ActionCable::Helpers::ActionCableHelper
+ 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