module Sequel::Database::SQLComments
Attributes
comment_hashes[R]
A map of threads to comment hashes, used for correctly setting comments for all queries inside with_comments blocks.
Public Class Methods
extended(db)
click to toggle source
# File lib/sequel/extensions/sql_comments.rb, line 142 def self.extended(db) db.instance_variable_set(:@comment_hashes, {}) db.extend_datasets DatasetSQLComments end
Public Instance Methods
with_comments(comment_hash) { |synchronize{hashes = new_hash}| ... }
click to toggle source
Store the comment hash and use it to create comments inside the block
# File lib/sequel/extensions/sql_comments.rb, line 152 def with_comments(comment_hash) hashes = @comment_hashes t = Sequel.current new_hash = if hash = Sequel.synchronize{hashes[t]} hash.merge(comment_hash) else comment_hash.dup end yield Sequel.synchronize{hashes[t] = new_hash} ensure if hash Sequel.synchronize{hashes[t] = hash} else t && Sequel.synchronize{hashes.delete(t)} end end