lib/upsert/buffer.rb in upsert-0.1.0 vs lib/upsert/buffer.rb in upsert-0.1.1
- old
+ new
@@ -15,24 +15,32 @@
DOUBLE_QUOTE = %{"}
BACKTICK = %{`}
E_AND_SINGLE_QUOTE = %{E'}
X_AND_SINGLE_QUOTE = %{x'}
USEC_SPRINTF = '%06d'
- ISO8601_DATETIME = '%Y-%m-%d %H:%M:%S' #FIXME ignores timezones i think
+ ISO8601_DATETIME = '%Y-%m-%d %H:%M:%S'
attr_reader :connection
attr_reader :table_name
attr_reader :rows
- attr_writer :async
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