Sha256: 4e1c9a9dc01aec7b6dd364a2546a3ff3be0841c750c5ca5dadd7f7987df82874
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
class Upsert # @private class Buffer class << self def for(connection, table_name) if connection.respond_to?(:raw_connection) # deal with ActiveRecord::Base.connection or ActiveRecord::Base.connection_pool.checkout connection = connection.raw_connection end const_get(connection.class.name.gsub(/\W+/, '_')).new connection, table_name end end SINGLE_QUOTE = %{'} DOUBLE_QUOTE = %{"} BACKTICK = %{`} E_AND_SINGLE_QUOTE = %{E'} X_AND_SINGLE_QUOTE = %{x'} USEC_SPRINTF = '%06d' ISO8601_DATETIME = '%Y-%m-%d %H:%M:%S' attr_reader :connection attr_reader :table_name attr_reader :rows def initialize(connection, table_name) @connection = connection @table_name = table_name @rows = [] end def async? !!@async end def async! @async = true end def sync! @async = false clear end def add(selector, document) rows << Row.new(self, selector, document) if sql = chunk execute sql end end def clear while sql = chunk execute sql end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
upsert-0.1.2 | lib/upsert/buffer.rb |
upsert-0.1.1 | lib/upsert/buffer.rb |