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 |
# 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['backtrace'].kind_of? String) backtraces = full_hash['backtrace'] else backtraces = full_hash['backtrace'].join('\n') end digest = Digest::SHA1.hexdigest(backtraces) notices = Notice.find_all_by_backtrace_digest(digest) notices = notices.reject! { |i| i.backtrace != full_hash['backtrace'] } if notices and notices.length > 0 notices[0].count += 1 return notices[0] end notice = Notice.create(full_hash) notice.backtrace_digest = digest 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 |