Sha256: 60b51f759055a4d085fd1dc0b36b3e0e1057263eefec85388b3f8a8f55f7c53d

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

module ContentState
  class StateError < StandardError
  end

  class StateNotSerializable < StateError
  end

  class Base
    include Reloadable

    class << self
      def instance
        nil
      end

      protected :new
    end

    def memento
      self.class.to_s
    end

    def exit_hook(content, target_state)
      logger.debug("#{content} leaving state #{self.memento}")
    end

    def enter_hook(content)
      logger.debug("#{content} entering state #{self.memento}")
    end

    def before_save(content)
      true
    end

    def after_save(content)
      true
    end

    def withdraw(content)
    end

    def mark_as_spam(content)
      content.state = Factory.new(:just_marked_as_spam)
    end

    def mark_as_ham(content)
      content.state = Factory.new(:just_marked_as_ham)
    end

    def published?(content)
      false
    end

    def just_published?
      false
    end

    def draft?
      false
    end

    def publication_pending?
      false
    end

    def withdrawn?
      false
    end

    def after_save(content)
      true
    end

    def post_trigger(content)
      true
    end

    def send_notifications(content, controller)
      true
    end

    def send_pings(content)
      true
    end

    def is_spam?(content)
      false
    end

    def logger
      @logger ||= RAILS_DEFAULT_LOGGER || Logger.new(STDERR)
    end

    def confirm_classification(content)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typo-4.0.2 app/models/content_state/base.rb
typo-4.0.1 app/models/content_state/base.rb