class ActiveSupport::CurrentAttributes
def set(set_attributes)
end
end
Chat::Publisher.publish(attributes: attributes, room_number: room_number)
Current.set(person: creator) do
def perform(attributes, room_number, creator)
class Chat::PublicationJob < ApplicationJob
Example demonstrating the common use of needing to set Current attributes outside the request-cycle:
Expose one or more attributes within a block. Old values are returned after the block concludes.
def set(set_attributes) old_attributes = compute_attributes(set_attributes.keys) assign_attributes(set_attributes) yield ensure assign_attributes(old_attributes) end