# File lib/hoptoad_notifier/notice.rb, line 68 def initialize(args) self.args = args self.exception = args[:exception] self.api_key = args[:api_key] self.project_root = args[:project_root] self.url = args[:url] || rack_env(:url) self.notifier_name = args[:notifier_name] self.notifier_version = args[:notifier_version] self.notifier_url = args[:notifier_url] self.ignore = args[:ignore] || [] self.ignore_by_filters = args[:ignore_by_filters] || [] self.backtrace_filters = args[:backtrace_filters] || [] self.params_filters = args[:params_filters] || [] self.parameters = args[:parameters] || action_dispatch_params || rack_env(:params) || {} self.component = args[:component] || args[:controller] || parameters['controller'] self.action = args[:action] || parameters['action'] self.environment_name = args[:environment_name] self.cgi_data = args[:cgi_data] || args[:rack_env] self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller), :filters => self.backtrace_filters) self.error_class = exception_attribute(:error_class) {|exception| exception.class.name } self.error_message = exception_attribute(:error_message, 'Notification') do |exception| "#{exception.class.name}: #{exception.message}" end also_use_rack_params_filters find_session_data clean_params end
Allows properties to be accessed using a hash-like syntax
@example
notice[:error_message]
@param [String] method The given key for an attribute @return The attribute value, or self if given :request
# File lib/hoptoad_notifier/notice.rb, line 172 def [](method) case method when :request self else send(method) end end
Determines if this notice should be ignored
# File lib/hoptoad_notifier/notice.rb, line 161 def ignore? ignored_class_names.include?(error_class) || ignore_by_filters.any? {|filter| filter.call(self) } end
Converts the given notice to XML
# File lib/hoptoad_notifier/notice.rb, line 104 def to_xml builder = Builder::XmlMarkup.new builder.instruct! xml = builder.notice(:version => HoptoadNotifier::API_VERSION) do |notice| notice.tag!("api-key", api_key) notice.notifier do |notifier| notifier.name(notifier_name) notifier.version(notifier_version) notifier.url(notifier_url) end notice.error do |error| error.tag!('class', error_class) error.message(error_message) error.backtrace do |backtrace| self.backtrace.lines.each do |line| backtrace.line(:number => line.number, :file => line.file, :method => line.method) end end end if url || controller || action || !parameters.blank? || !cgi_data.blank? || !session_data.blank? notice.request do |request| request.url(url) request.component(controller) request.action(action) unless parameters.nil? || parameters.empty? request.params do |params| xml_vars_for(params, parameters) end end unless session_data.nil? || session_data.empty? request.session do |session| xml_vars_for(session, session_data) end end unless cgi_data.nil? || cgi_data.empty? request.tag!("cgi-data") do |cgi_datum| xml_vars_for(cgi_datum, cgi_data) end end end end notice.tag!("server-environment") do |env| env.tag!("project-root", project_root) env.tag!("environment-name", environment_name) end end xml.to_s end
Generated with the Darkfish Rdoc Generator 2.