module Changed
Constants
- Field
- OPTIONS_REQUEST_STORE_KEY
- Relationship
- VERSION
Public Class Methods
changer()
click to toggle source
Access the changer (this value is set as the changer within an audit and defaults to config).
# File lib/changed.rb, line 40 def self.changer options[:changer] || config.default_changer_proc&.call end
changer=(changer)
click to toggle source
config()
click to toggle source
options()
click to toggle source
# File lib/changed.rb, line 85 def self.options RequestStore.store[OPTIONS_REQUEST_STORE_KEY] ||= {} end
options=(options)
click to toggle source
# File lib/changed.rb, line 81 def self.options=(options) RequestStore.store[OPTIONS_REQUEST_STORE_KEY] = options end
perform(options = {}, &block)
click to toggle source
Perform a block with custom override options.
Attributes¶ ↑
-
options
- Values for the changer and / or timestamp. -
block
- Some code to run with the new options.
Examples¶ ↑
Changed.perform(changer: User.system, timestamp: 2.hours.ago) do widget.name = "Sprocket" widget.save! end
# File lib/changed.rb, line 70 def self.perform(options = {}, &block) backup = self.options self.options = options block.call ensure self.options = backup end
timestamp()
click to toggle source
Access the timestamp (this value is set as the timestamp within an audit and defaults to now).
# File lib/changed.rb, line 22 def self.timestamp options[:timestamp] || Time.now end
timestamp=(timestamp)
click to toggle source