Class: Hitchens::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/hitchens/post.rb

Instance Method Summary collapse

Instance Method Details

#publishedObject



13
14
15
16
# File 'app/models/hitchens/post.rb', line 13

def published
  return false unless publication_date
  publication_date < Time.now
end

#published=(value) ⇒ Object



6
7
8
9
10
11
12
# File 'app/models/hitchens/post.rb', line 6

def published=(value)
  if ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
    self.publication_date = Time.now unless publication_date
  else
    self.publication_date = nil
  end
end