Sha256: 4c29724138a344d24301bd7f1f53054c7a34bf7af3ce46ff276fdc9f841a4a43

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

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

      private

      def projectlocker_errata_javascript_notifier
        return unless ProjectlockerErrata.configuration.public?

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

        options              = {
          :file              => path,
          :layout            => false,
          :use_full_path     => false,
          :locals            => {
            :host            => host,
            :api_key         => ProjectlockerErrata.configuration.js_api_key,
            :environment     => ProjectlockerErrata.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

4 entries across 4 versions & 1 rubygems

Version Path
projectlocker_errata-0.1.1 lib/projectlocker_errata/rails/javascript_notifier.rb
projectlocker_errata-0.1.0 lib/projectlocker_errata/rails/javascript_notifier.rb
projectlocker_errata-0.0.2 lib/projectlocker_errata/rails/javascript_notifier.rb
projectlocker_errata-0.0.1 lib/projectlocker_errata/rails/javascript_notifier.rb