Class: Jiminy::Recording::NPlusOne
- Inherits:
-
Object
- Object
- Jiminy::Recording::NPlusOne
- Defined in:
- lib/jiminy/recording/n_plus_one.rb
Constant Summary collapse
- LOCATION_REGEXP =
%r{^ (?<file>[\w_\-/.]+\.(?:erb|rb|jbuilder)): (?<line>\d+):in\s`(?:block\sin\s)? (?<method>[^']+)'?}x.freeze
- EXAMPLES_COUNT =
3
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(location:, queries: []) ⇒ NPlusOne
constructor
A new instance of NPlusOne.
- #to_h ⇒ Object
Constructor Details
#initialize(location:, queries: []) ⇒ NPlusOne
Returns a new instance of NPlusOne.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jiminy/recording/n_plus_one.rb', line 15 def initialize(location:, queries: []) @location = location.to_s.strip @queries = queries match_result = location.match(LOCATION_REGEXP) @file = match_result[:file] @line = match_result[:line] @method_name = match_result[:method] freeze end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/jiminy/recording/n_plus_one.rb', line 6 def file @file end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/jiminy/recording/n_plus_one.rb', line 6 def location @location end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 |
# File 'lib/jiminy/recording/n_plus_one.rb', line 27 def ==(other) location == other.location end |
#to_h ⇒ Object
31 32 33 34 35 |
# File 'lib/jiminy/recording/n_plus_one.rb', line 31 def to_h { location => attributes } end |