Class: Cachai::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/models.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_or_create_by_path(path) ⇒ Object



105
106
107
# File 'lib/models.rb', line 105

def self.find_or_create_by_path(path)
  find_by_path(path) || create({:path => path})
end

Instance Method Details

#clear_cacheObject



121
122
123
# File 'lib/models.rb', line 121

def clear_cache
  Cachai.clear_cache(path)
end

#comments_closed?(days_to_remain_open) ⇒ Boolean

Returns:

  • (Boolean)


109
110
111
112
113
114
115
116
117
118
119
# File 'lib/models.rb', line 109

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