Sha256: cccb4ee27b0222ba3496b4737b2d6cbf0ca3573591877543d285a420ffe39e3e

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

module Chatterbox::ExceptionNotification
  class RailsExtracter
    def self.wrap(notification = {})
      new(notification).notice
    end

    def initialize(message = {})
      @message = message
    end

    def notice
      hsh = extract_rails_info(@message)
      hsh = extract_request_info(hsh)
      hsh
    end

    def rails_configuration
      Object.const_get("Rails") if Object.const_defined?("Rails")
    end

    def extract_rails_info(message)
      return message if rails_configuration.nil?
      message.merge({
        :rails_info => {
          :rails_env => rails_configuration.env.to_s,
          :rails_root => rails_configuration.root.to_s,
          :rails_version => rails_configuration.version
        }
      })
    end
    
    def extract_request_info(message)
      return message unless message.key?(:request)
      request = message.delete(:request)
      message.merge({
        :request => {
          :url => request.url,
          :remote_ip => request.remote_ip,
          :parameters => request.parameters
        }
      })
    end
  end
end


# 
# * URL       : <%= @request.protocol %><%= @host %><%= @request.request_uri %>
# * IP address: <%= @request.env["HTTP_X_FORWARDED_FOR"] || @request.env["REMOTE_ADDR"] %>
# * Parameters: <%= filter_sensitive_post_data_parameters(@request.parameters).inspect %>
# * Rails root: <%= @rails_root %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chatterbox-0.5.1 lib/chatterbox/exception_notification/rails_extracter.rb