module GetSchwifty::Helper

:nodoc

Public Instance Methods

get_schwifty(route, params = nil, &blk) click to toggle source
# File lib/get_schwifty/helper.rb, line 4
def get_schwifty(route, params = nil, &blk)
  id = SecureRandom.hex
  Rails.cache.write("get_schwifty:#{id}", route)

  opts = {
    "data-get-schwifty" => id
  }

  opts["data-get-schwifty-params"] = params.to_json if params

  args = [
    :div, nil, opts
  ]

  if block_given?
    args.reject!(&:nil?)
    return content_tag(*args, &blk)
  end

  content_tag(*args)
end