Class: Shiba::Console::ExplainRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/shiba/console.rb

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ ExplainRecord

Returns a new instance of ExplainRecord.



27
28
29
# File 'lib/shiba/console.rb', line 27

def initialize(fields)
  @fields = fields
end

Instance Method Details

#commentsObject



31
32
33
34
35
# File 'lib/shiba/console.rb', line 31

def comments
  # renderer expects json / key strings
  json = JSON.parse(JSON.dump(@fields))
  renderer.render(json)
end

#helpObject



65
66
67
# File 'lib/shiba/console.rb', line 65

def help
  "Available methods: #{self.class.public_instance_methods(false)}"
end

#inspectObject



69
70
71
# File 'lib/shiba/console.rb', line 69

def inspect
  "#{to_s}: '#{sql}'. Call the 'help' method on this object for more info."
end

#md5Object



37
38
39
# File 'lib/shiba/console.rb', line 37

def md5
  @fields[:md5]
end

#messageObject



57
58
59
60
61
62
63
# File 'lib/shiba/console.rb', line 57

def message
  msg = "\n"
  msg << "Severity: #{severity}\n"
  msg << "----------------------------\n"
  msg << comments
  msg << "\n\n"
end

#raw_explainObject



53
54
55
# File 'lib/shiba/console.rb', line 53

def raw_explain
  @fields[:raw_explain]
end

#severityObject



41
42
43
# File 'lib/shiba/console.rb', line 41

def severity
  @fields[:severity]
end

#sqlObject



45
46
47
# File 'lib/shiba/console.rb', line 45

def sql
  @fields[:sql]
end

#timeObject



49
50
51
# File 'lib/shiba/console.rb', line 49

def time
  @fields[:cost]
end