Classes and Modules
Attributes
comment_hashes | [R] |
A map of threads to comment hashes, used for correctly setting comments for all queries inside |
Public Class methods
extended(db)
[show source]
# File lib/sequel/extensions/sql_comments.rb 143 def self.extended(db) 144 db.instance_variable_set(:@comment_hashes, {}) 145 db.extend_datasets DatasetSQLComments 146 end
Public Instance methods
with_comments(comment_hash)
Store the comment hash and use it to create comments inside the block
[show source]
# File lib/sequel/extensions/sql_comments.rb 153 def with_comments(comment_hash) 154 hashes = @comment_hashes 155 t = Sequel.current 156 new_hash = if hash = Sequel.synchronize{hashes[t]} 157 hash.merge(comment_hash) 158 else 159 comment_hash.dup 160 end 161 yield Sequel.synchronize{hashes[t] = new_hash} 162 ensure 163 if hash 164 Sequel.synchronize{hashes[t] = hash} 165 else 166 t && Sequel.synchronize{hashes.delete(t)} 167 end 168 end