Sha256: fba83a19c8a38406feb2968e80b2b014a6644922b814df573c40e249b74573cb
Contents?: true
Size: 935 Bytes
Versions: 7
Compression:
Stored size: 935 Bytes
Contents
# frozen_string_literal: true module Snapcher class Sweeper STORED_DATA = { current_remote_address: :remote_ip, current_request_uuid: :request_uuid, current_user: :current_user } delegate :store, to: ::Snapcher def around(controller) self.controller = controller STORED_DATA.each { |k, m| store[k] = send(m) } yield ensure self.controller = nil STORED_DATA.keys.each { |k| store.delete(k) } end def current_user lambda { controller.send(Snapcher.current_user_method) if controller.respond_to?(Snapcher.current_user_method, true) } end def remote_ip controller.try(:request).try(:remote_ip) end def request_uuid controller.try(:request).try(:uuid) end def controller store[:current_controller] end def controller=(value) store[:current_controller] = value end end end
Version data entries
7 entries across 7 versions & 1 rubygems