just_published.rb

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

RB
48
字号
module ContentState  class JustPublished < Published    include Singleton    # We need to save the state as 'Published', but we need after_save    # to be handled by JustPublished. So, JustPublished tells Rails that    # it's *actually* Published and all shall be well.    def memento      'ContentState::Published'    end    def just_published?      true    end    def just_changed_published_status?      true    end    def published?(content)      true    end#    def enter_hook(content)#      super#    end#    def set_published_at(content, new_time)#      super#    end    def send_notifications(content)      content.interested_users.each do |user|        content.send_notification_to_user(user)      end    end    def send_pings(content)      content.really_send_pings    end    def withdraw(content)      content[:published_at] = nil      content.state = Factory.new(:draft)    end  endend

⌨️ 快捷键说明

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