module ActsAsExpirable::Expirable
Public Instance Methods
expire()
click to toggle source
# File lib/acts_as_expirable/expirable.rb, line 42 def expire write_attribute(expiry_column, Time.now) end
expire!()
click to toggle source
# File lib/acts_as_expirable/expirable.rb, line 46 def expire! update_attribute(expiry_column, Time.now) end
expired?()
click to toggle source
# File lib/acts_as_expirable/expirable.rb, line 50 def expired? expire_time = read_attribute(expiry_column) return false if expire_time.nil? expire_time <= Time.now end
expiry_column()
click to toggle source
# File lib/acts_as_expirable/expirable.rb, line 38 def expiry_column self.class.expiry_column end
Protected Instance Methods
set_expiry_default()
click to toggle source
# File lib/acts_as_expirable/expirable.rb, line 58 def set_expiry_default default = acts_as_expirable_configuration[:default] return true if default.nil? # set the value if the current value is not set if read_attribute(acts_as_expirable_configuration[:column]).nil? write_attribute(acts_as_expirable_configuration[:column], default.respond_to?(:call) ? default.call(self) : default ) end true end