draft.rb

来自「用ruby on rails写的一个博客程序,还不错..ruby on rail」· RB 代码 · 共 33 行

RB
33
字号
module ContentState  class Draft < Base    include Singleton    def enter_hook(content)      super      content[:published] = false      content[:published_at] = nil    end    def change_published_state(content, boolean)      content[:published] = boolean      if boolean        content.state = JustPublished.instance      end    end    def set_published_at(content, new_time)      content[:published_at] = new_time      return if new_time.nil?      if new_time <= Time.now        content[:published_at] = nil      else        content.state = PublicationPending.instance      end    end    def draft?      true    end  endend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?