Sha256: 8e23fbd4e8c0f821635ea053227d5b8fb2b827bc0aa62120946402795ffb487b

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module Pulse
  module Rails
    module JavascriptNotifier
      def self.included(base) #:nodoc:
        base.send :helper_method, :pulse_javascript_notifier
      end

      private

      def pulse_javascript_notifier
        return unless Pulse.configuration.public?

        path = File.join File.dirname(__FILE__), '..', '..', 'templates', 'javascript_notifier.erb'
        host = Pulse.configuration.host.dup
        port = Pulse.configuration.port
        host << ":#{port}" unless [80, 443].include?(port)

        options              = {
          :file              => path,
          :layout            => false,
          :use_full_path     => false,
          :locals            => {
            :host            => host,
            :api_key         => Pulse.configuration.js_api_key,
            :environment     => Pulse.configuration.environment_name,
            :action_name     => action_name,
            :controller_name => controller_name,
            :url             => request.url
          }
        }

        res = if @template
          @template.render(options)
        else
          render_to_string(options)
        end

        if res.respond_to?(:html_safe)
          res.html_safe
        else
          res
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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