instance method
set
Ruby on Rails 8.0.4
Since v5.2.8.1Signature
set(attributes, &block)
Expose one or more attributes within a block. Old values are returned after the block concludes. Example demonstrating the common use of needing to set Current attributes outside the request-cycle:
class Chat::PublicationJob < ApplicationJob def perform(attributes, room_number, creator) Current.set(person: creator) do Chat::Publisher.publish(attributes: attributes, room_number: room_number) end end end
Parameters
-
attributesreq -
blockblock
Source
# File activesupport/lib/active_support/current_attributes.rb, line 220
def set(attributes, &block)
with(**attributes, &block)
end
Defined in activesupport/lib/active_support/current_attributes.rb line 220
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::CurrentAttributes