class Turbot::Handlers::PreviewHandler
Attributes
count[R]
Public Class Methods
new(bot_name, api)
click to toggle source
# File lib/turbot/handlers/preview_handler.rb, line 6 def initialize(bot_name, api) @bot_name = bot_name @api = api @count = 0 @batch = [] end
Public Instance Methods
handle_valid_record(record, data_type)
click to toggle source
Implements `TurbotRunner::BaseHandler#handle_valid_record`.
# File lib/turbot/handlers/preview_handler.rb, line 14 def handle_valid_record(record, data_type) @count += 1 STDOUT.write('.') @batch << record.merge(:data_type => data_type) if @count % 20 == 0 submit_batch end end
submit_batch()
click to toggle source
# File lib/turbot/handlers/preview_handler.rb, line 23 def submit_batch result = @api.create_draft_data(@bot_name, @batch.to_json) @batch = [] result end