Module: MagicUserstamp::Stamper::InstanceMethods
- Defined in:
- lib/magic_userstamp/stamper.rb
Instance Method Summary collapse
-
#reset_stamper ⇒ Object
Sets the stamper back to
nil
to prepare for the next request. -
#stamper ⇒ Object
Retrieves the existing stamper for the current request.
-
#stamper=(object) ⇒ Object
Used to set the stamper for a particular request.
Instance Method Details
#reset_stamper ⇒ Object
Sets the stamper back to nil
to prepare for the next request.
36 37 38 |
# File 'lib/magic_userstamp/stamper.rb', line 36 def reset_stamper Thread.current["#{self.to_s.downcase}_#{self.object_id}_stamper"] = nil end |
#stamper ⇒ Object
Retrieves the existing stamper for the current request.
31 32 33 |
# File 'lib/magic_userstamp/stamper.rb', line 31 def stamper Thread.current["#{self.to_s.downcase}_#{self.object_id}_stamper"] end |
#stamper=(object) ⇒ Object
Used to set the stamper for a particular request. See the MagicUserstamp module for more details on how to use this method.
20 21 22 23 24 25 26 27 28 |
# File 'lib/magic_userstamp/stamper.rb', line 20 def stamper=(object) object_stamper = if object.is_a?(ActiveRecord::Base) object.send("#{object.class.primary_key}".to_sym) else object end Thread.current["#{self.to_s.downcase}_#{self.object_id}_stamper"] = object_stamper end |