class Sweatpants::QueuedRequest

Public Class Methods

new(method, params) click to toggle source
# File lib/sweatpants/queued_request.rb, line 5
def initialize method, params
  @method = method
  @type = params[:type] || nil
  @index = params[:index] || nil
  @id = params[:id] || nil
  @body = params[:body] || nil
end

Public Instance Methods

bulk_header() click to toggle source
# File lib/sweatpants/queued_request.rb, line 17
def bulk_header
  header = { @method.to_sym => { _index: @index, _type: @type } }
  header[:id] = @id if @id
  header
end
to_bulk() click to toggle source
# File lib/sweatpants/queued_request.rb, line 13
def to_bulk
  [bulk_header, @body].map(&:to_json).join("\n")
end