lib/models.rb in cachai-0.2.4 vs lib/models.rb in cachai-0.2.5
- old
+ new
@@ -104,9 +104,21 @@
def self.find_or_create_by_path(path)
find_by_path(path) || create({:path => path})
end
+ def comments_closed?(days_to_remain_open)
+ return true if comments_allowed.to_i == 0
+
+ return false if !days_to_remain_open
+
+ # ok, we got an expiration period (seconds)
+ # if we add it to the creation date and it's past
+ # that date then yes, comments are closed.
+
+ (created_at + days_to_remain_open) < Time.now
+ end
+
def clear_cache
Cachai.clear_cache(path)
end
end