Sha256: 86ac1c97b1be7406b767210179685637aabb851f4a1ac07a24aa98d7f136a2ce

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require 'projectlocker_pulse'
require 'pulse/rails/controller_methods'
require 'pulse/rails/action_controller_catcher'
require 'pulse/rails/error_lookup'
require 'pulse/rails/javascript_notifier'

module Pulse
  module Rails
    def self.initialize
      if defined?(ActionController::Base)
        ActionController::Base.send(:include, Pulse::Rails::ActionControllerCatcher)
        ActionController::Base.send(:include, Pulse::Rails::ErrorLookup)
        ActionController::Base.send(:include, Pulse::Rails::ControllerMethods)
        ActionController::Base.send(:include, Pulse::Rails::JavascriptNotifier)
      end

      rails_logger = if defined?(::Rails.logger)
                       ::Rails.logger
                     elsif defined?(RAILS_DEFAULT_LOGGER)
                       RAILS_DEFAULT_LOGGER
                     end

      if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
        ::Rails.configuration.middleware.insert_after 'ActionController::Failsafe',
                                                      Pulse::Rack
        ::Rails.configuration.middleware.insert_after 'Rack::Lock',
                                                      Pulse::UserInformer
      end

      Pulse.configure(true) do |config|
        config.logger           = rails_logger
        config.environment_name = defined?(::Rails.env) && ::Rails.env || defined?(RAILS_ENV) && RAILS_ENV
        config.project_root     = defined?(::Rails.root) && ::Rails.root || defined?(RAILS_ROOT) && RAILS_ROOT
        config.framework        = defined?(::Rails.version) && "Rails: #{::Rails.version}" || defined?(::Rails::VERSION::STRING) && "Rails: #{::Rails::VERSION::STRING}"
      end
    end
  end
end

Pulse::Rails.initialize

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
projectlocker_pulse-1.0.0 lib/pulse/rails.rb
projectlocker_pulse-0.2.1 lib/pulse/rails.rb