module Wrappi::AsyncConcern

Public Instance Methods

wrappi_perform(endpoint_class, args, options) click to toggle source
# File lib/wrappi/async_job.rb, line 3
def wrappi_perform(endpoint_class, args, options)
  @endpoint_class = endpoint_class
  @args = parse(args)
  @options = parse(options)
  return unless endpoint_const
  inst = endpoint_const.new(@args[:params], @args[:options])
  inst.perform_async_callback(@options)
end

Private Instance Methods

endpoint_const() click to toggle source
# File lib/wrappi/async_job.rb, line 25
def endpoint_const
  Class.const_get(@endpoint_class)
rescue
  puts "[Wrappi] Unable to find const #{@endpoint_class} for async"
  false
end
ia(data) click to toggle source
# File lib/wrappi/async_job.rb, line 21
def ia(data)
  Fusu::HashWithIndifferentAccess.new(data)
end
parse(data) click to toggle source
# File lib/wrappi/async_job.rb, line 14
def parse(data)
  return ia(data) if data.is_a?(Hash)
  ia(JSON.parse(data)) rescue {}
rescue
  data
end