class Data::Invoker

Public Class Methods

new(batch_action, ids) click to toggle source
# File lib/tabulatr/data/invoker.rb, line 25
def initialize(batch_action, ids)
  @batch_action = batch_action.to_sym
  @ids = ids
  @result = nil
end

Public Instance Methods

method_missing(name, *args) { |ids| ... } click to toggle source
# File lib/tabulatr/data/invoker.rb, line 31
def method_missing(name, *args, &block)
  @result ||= if @batch_action == name
    s = yield(@ids)
    if s.is_a?(Hash) && s[:data]
      Tabulatr::Responses::RawResponse.new(s[:data], filename: s[:filename], type: s[:type])
    elsif s.is_a?(Hash) && s[:file]
      Tabulatr::Responses::FileResponse.new(s[:file], filename: s[:filename], type: s[:type])
    elsif s.is_a?(Hash) && s[:url]
      Tabulatr::Responses::RedirectResponse.new(s[:url], ids: @ids)
    else
      s
    end
  end
end