Module: Acts::Expireable::InstanceMethods
- Defined in:
- lib/acts/expireable.rb
Overview
:nodoc:
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
:nodoc:
51 52 53 |
# File 'lib/acts/expireable.rb', line 51 def self.included(base) # :nodoc: base.extend ClassMethods end |
Instance Method Details
#expire ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/acts/expireable.rb', line 55 def expire self.on_expire if respond_to? :on_expire self.destroy if self.class.respawn self.on_respawn if respond_to? :on_respawn self.class.new.save end end |
#setup_expireable ⇒ Object
72 73 74 75 |
# File 'lib/acts/expireable.rb', line 72 def setup_expireable self.expires_at = Time.now + self.class.lifespan self.spawn_at = Time.now + self.class.delay end |
#spawn ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/acts/expireable.rb', line 64 def spawn if !spawned? self.on_spawn if respond_to? :on_spawn self.spawn_at = nil save end end |
#spawned? ⇒ Boolean
77 78 79 |
# File 'lib/acts/expireable.rb', line 77 def spawned? self.spawn_at == nil end |