Module: Publishable::InstanceMethods

Defined in:
lib/publishable.rb

Instance Method Summary collapse

Instance Method Details

#publish(time = Time.now) ⇒ Object



23
24
25
# File 'lib/publishable.rb', line 23

def publish(time = Time.now)
  self.published_at = time unless published?
end

#publish!(time = Time.now) ⇒ Object



27
28
29
# File 'lib/publishable.rb', line 27

def publish!(time = Time.now)
  publish(time) && save
end

#published?(time = Time.now) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/publishable.rb', line 19

def published?(time = Time.now)
  published_at ? published_at <= time : false
end