0d83e9b90c
Remove variables name for block, not needed from Ruby >= 3.1
23 lines
497 B
Ruby
23 lines
497 B
Ruby
class Current < ActiveSupport::CurrentAttributes
|
|
attribute :session, :user, :account
|
|
attribute :http_method, :request_id, :user_agent, :ip_address, :referrer
|
|
|
|
delegate :identity, to: :session, allow_nil: true
|
|
|
|
def session=(value)
|
|
super(value)
|
|
|
|
if value.present? && account.present?
|
|
self.user = identity.users.find_by(account: account)
|
|
end
|
|
end
|
|
|
|
def with_account(value, &)
|
|
with(account: value, &)
|
|
end
|
|
|
|
def without_account(&)
|
|
with(account: nil, &)
|
|
end
|
|
end
|