Class: N1Finder::Adapters::BaseAdapter
- Inherits:
-
Object
- Object
- N1Finder::Adapters::BaseAdapter
- Defined in:
- lib/n_1_finder/adapters/base_adapter.rb
Overview
Adds common functionality to other adapters
Direct Known Subclasses
Constant Summary collapse
- MAIN_METHOD_ALIAS =
An alias that we create for MAIN_METHOD function
:main_method_alias
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#exec { ... } ⇒ Object
Replaces original query execution function (defined in MAIN_METHOD) with our function that collects all queries and calls original function.
-
#initialize(storage) ⇒ BaseAdapter
constructor
A new instance of BaseAdapter.
Constructor Details
#initialize(storage) ⇒ BaseAdapter
Returns a new instance of BaseAdapter.
14 15 16 |
# File 'lib/n_1_finder/adapters/base_adapter.rb', line 14 def initialize(storage) @storage = storage end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
12 13 14 |
# File 'lib/n_1_finder/adapters/base_adapter.rb', line 12 def storage @storage end |
Instance Method Details
#exec { ... } ⇒ Object
Replaces original query execution function (defined in MAIN_METHOD) with our function that collects all queries and calls original function. After passed block yileds, replaces our function with origianal and removes our function.
26 27 28 29 30 31 |
# File 'lib/n_1_finder/adapters/base_adapter.rb', line 26 def exec set_trap yield ensure remove_trap end |