Class: Whoops::Event

Inherits:
Object
  • Object
show all
Includes:
FieldNames, Mongoid::Document
Defined in:
app/models/whoops/event.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search(query) ⇒ Object



18
19
20
21
# File 'app/models/whoops/event.rb', line 18

def self.search(query)
  conditions = Whoops::MongoidSearchParser.new(query).conditions
  where(conditions)
end

Instance Method Details

#all_keys(values) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'app/models/whoops/event.rb', line 52

def all_keys(values)
  keys = []
  values.each do |value|
    if value.is_a? Hash
      keys |= value.keys
      keys |= all_keys(value.values)
    end
  end
  keys
end

#sanitize_detailsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/whoops/event.rb', line 30

def sanitize_details
  if details.is_a? Hash
    sanitized_details = {}
    details.each do |key, value|
      if key =~ /\./
        key = key.gsub(/\./, "_")
      end
      
      if value.is_a? Hash
        child_keys = all_keys([value])
        if child_keys.any?{ |child_key| child_key =~ /\./ } 
          value = value.to_s
        end
      end
      
      sanitized_details[key] = value
    end
    
    self.details = sanitized_details
  end
end

#set_keywordsObject



23
24
25
26
27
28
# File 'app/models/whoops/event.rb', line 23

def set_keywords
  keywords_array = []
  keywords_array << self.message
  add_details_to_keywords(keywords_array)
  self.keywords = keywords_array.join(" ")
end