Module: SqlTagger::Initializer
- Defined in:
- lib/sql_tagger.rb
Overview
Instance Attribute Summary collapse
-
#sql_tagger ⇒ SqlTagger
The SqlTagger used to tag queries for this instance.
Class Method Summary collapse
-
.included(base) ⇒ Object
Callback that monkey patches the receiver’s
initializemethod to set @sql_tagger.
Instance Method Summary collapse
-
#initialize_with_sql_tagger(*args, &block) ⇒ Object
Sets @sql_tagger before initializing.
Instance Attribute Details
#sql_tagger ⇒ SqlTagger
Returns the SqlTagger used to tag queries for this instance.
83 84 85 |
# File 'lib/sql_tagger.rb', line 83 def sql_tagger @sql_tagger end |
Class Method Details
.included(base) ⇒ Object
Callback that monkey patches the receiver’s initialize method to set @sql_tagger.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/sql_tagger.rb', line 71 def self.included(base) base.send(:alias_method, :initialize_without_sql_tagger, :initialize) base.send(:alias_method, :initialize, :initialize_with_sql_tagger) # This is for the odd case where a SQL gem/library is used before # sql_tagger is required. ObjectSpace.each_object(base) do |obj| obj.sql_tagger ||= SqlTagger.default end end |
Instance Method Details
#initialize_with_sql_tagger(*args, &block) ⇒ Object
Sets @sql_tagger before initializing
86 87 88 89 |
# File 'lib/sql_tagger.rb', line 86 def initialize_with_sql_tagger(*args, &block) @sql_tagger = SqlTagger.default initialize_without_sql_tagger(*args, &block) end |