Class: RSpec::Sql::QuerySummary
- Inherits:
-
Object
- Object
- RSpec::Sql::QuerySummary
- Defined in:
- lib/rspec/sql/query_summary.rb
Overview
Converts a list of queries into a summary hash.
Constant Summary collapse
- QUERY_TYPES =
%i[delete insert select update].freeze
Instance Attribute Summary collapse
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Instance Method Summary collapse
-
#initialize(queries) ⇒ QuerySummary
constructor
A new instance of QuerySummary.
Constructor Details
#initialize(queries) ⇒ QuerySummary
Returns a new instance of QuerySummary.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec/sql/query_summary.rb', line 11 def initialize(queries) @summary = {} queries.each do |payload| type = get_type(payload[:sql]) next if QUERY_TYPES.exclude?(type) || pg_query?(payload[:sql]) table = get_table(payload[:sql]) @summary[type] ||= {} @summary[type][table] ||= 0 @summary[type][table] += 1 end end |
Instance Attribute Details
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
9 10 11 |
# File 'lib/rspec/sql/query_summary.rb', line 9 def summary @summary end |