MishkaBlog.Resources.Changes.PublishLifecycle (Mishka Blog v0.0.1)

Copy Markdown View Source

Keeps a post's publish times in step with its :status.

  • A post whose status is :published and that has no :published_at gets the current time, truncated to the second.
  • A post whose status is :scheduled and that has no :scheduled_publish_at is refused with an error on that field.
  • Any other status is left alone.

On a create it applies to every post. On an update it applies only when the status is changing, so saving an already published post never moves its :published_at.

Usage

create :create do
  change MishkaBlog.Resources.Changes.PublishLifecycle
end

update :update do
  change MishkaBlog.Resources.Changes.PublishLifecycle
end