diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-14 15:48:54 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-14 15:48:54 +0100 |
commit | bf40bddfceebaff637161be6c5d992d6978679ff (patch) | |
tree | b3541d5ec5015ab9459d1970a9f10fd37c0156c3 /actioncable/lib/action_cable/engine.rb | |
parent | 4073a3e3fe77141d09ed767224a1089796de2f7d (diff) | |
download | rails-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.rb | 27 |
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 |