Class: Notice
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Notice
- Defined in:
- app/models/notice.rb
Class Method Summary collapse
-
.from_hash(full_hash) ⇒ Object
Accepts a string or parsed YAML.
- .from_v1_yaml(str) ⇒ Object
-
.from_v2_xml(str) ⇒ Object
Accepts a string or parsed XML.
Class Method Details
.from_hash(full_hash) ⇒ Object
Accepts a string or parsed YAML
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/notice.rb', line 16 def self.from_hash(full_hash) full_hash = full_hash['notice'] if full_hash['notice'] if(full_hash['error']['backtrace'].kind_of? String) backtraces = full_hash['error']['backtrace'] else backtraces = full_hash['error']['backtrace']['line'] end digest = Digest::SHA1.hexdigest(backtraces.to_s) notices = Notice.find_all_by_backtrace_digest(digest) notices = notices.reject! { |i| i.backtrace != full_hash['error']['backtrace']['line'] } if notices and notices.length > 0 notices[0].count += 1 return notices[0] end # Convert to old format - ugly, but it works and doesn't break # all the views (yet) notice = Notice.new notice.api_key = full_hash['api_key'] notice. = full_hash['error']['message'] notice.error_class = full_hash['error']['class'] notice.backtrace_digest = digest notice.session = nil notice.environment = full_hash['server_environment']['environment_name'] notice.request = full_hash['request'] notice.backtrace = backtraces notice.count = 1 notice end |
.from_v1_yaml(str) ⇒ Object
10 11 12 13 |
# File 'app/models/notice.rb', line 10 def self.from_v1_yaml(str) full_yaml = YAML.load(str) if str.kind_of? String self.from_hash(full_yaml) end |
.from_v2_xml(str) ⇒ Object
Accepts a string or parsed XML
5 6 7 8 |
# File 'app/models/notice.rb', line 5 def self.from_v2_xml(str) full_xml = Hash.from_xml(str) if str.kind_of? String self.from_hash(full_xml) end |