Class: RspecSqlCounter::SqlFetcher
- Inherits:
-
Object
- Object
- RspecSqlCounter::SqlFetcher
- Defined in:
- lib/rspec_sql_counter/sql_fetcher.rb
Defined Under Namespace
Classes: SqlQueryInfo
Class Attribute Summary collapse
-
.queries ⇒ Object
readonly
Returns the value of attribute queries.
Class Method Summary collapse
-
.sql_queries(block) ⇒ Array<SqlQueryInfo>
Collects all sql queries called in the specified block of code.
Class Attribute Details
.queries ⇒ Object (readonly)
Returns the value of attribute queries.
19 20 21 |
# File 'lib/rspec_sql_counter/sql_fetcher.rb', line 19 def queries @queries end |
Class Method Details
.sql_queries(block) ⇒ Array<SqlQueryInfo>
Collects all sql queries called in the specified block of code
[
#<struct SqlHelper::SqlQueryInfo sql="SELECT COUNT(*) FROM \"companies\"", type_casted_binds=[], times=1>,
#<struct SqlHelper::SqlQueryInfo sql="SELECT \"companies\".* FROM \"companies\" LIMIT $1 OFFSET $2",
type_casted_binds=[10, 10], times=1>
]
30 31 32 33 34 35 36 37 38 |
# File 'lib/rspec_sql_counter/sql_fetcher.rb', line 30 def sql_queries(block) @queries = [] ActiveSupport::Notifications.subscribed(method(:active_support_callback), 'sql.active_record') do block.call end queries end |