class Sqreen::Ecosystem::ModuleApi::TransactionStorage::TxLocalVariables
Private Class Methods
attr_accessor(attr, opts = {})
click to toggle source
# File lib/sqreen/ecosystem/module_api/transaction_storage.rb, line 28 def attr_accessor(attr, opts = {}) # reader attr_reader attr, opts # writer (2 variants) do_assign = proc do |value| tx_storage = Ecosystem::TransactionStorage.fetch_thread_local unless tx_storage logger.debug do "Assignment of tx local attribute #{attr} to #{value} has no effect" end return end tx_storage[attr] = value end if opts.fetch(:allow_overwrite, false) define "#{attr}=", &do_assign else define_method "#{attr}=" do |value| cur = public_send(attr) unless cur.nil? raise "Cannot override value of #{attr} from #{cur} with #{value}" end do_assign.call(value) end end end
attr_reader(attr, _opts = {})
click to toggle source
# File lib/sqreen/ecosystem/module_api/transaction_storage.rb, line 20 def attr_reader(attr, _opts = {}) define_method attr do tx_storage = Ecosystem::TransactionStorage.fetch_thread_local return unless tx_storage tx_storage[attr] end end