Skip to content

Instantly share code, notes, and snippets.

View JoshAntBrown's full-sized avatar
🛠️
Building

Josh Brown JoshAntBrown

🛠️
Building
View GitHub Profile
@JoshAntBrown
JoshAntBrown / application_job.rb
Last active May 31, 2024 15:17
Serialize CurrentAttributes in ActiveJob
class ApplicationJob < ActiveJob::Base
def serialize
super.merge("current_account" => Current.account&.to_global_id&.to_s)
end
def deserialize(job_data)
account_global_id = job_data.delete("current_account")
Current.account = account_global_id ? GlobalID::Locator.locate(account_global_id) : nil
super
end
@JoshAntBrown
JoshAntBrown / template_render.js
Last active May 15, 2024 06:27
Template Renderer
class TemplateRenderer {
constructor(template) {
this.template = template
}
render(data) {
const clone = document.importNode(this.template.content, true)
this.#processNodes(clone, data)
return clone
}