Sha256: 8b6fabec93e7656431ca22735d43cf5b62f93a1782a84d8054c914fcf537d67c

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

module ContentState
  class StateError < StandardError
  end

  class StateNotSerializable < StateError
  end

  class InvalidMethodForState < StandardError
  end

  class Base
    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 just_changed_published_status?
      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(controller)
      true
    end

    def send_pings(content)
      true
    end

    def is_spam?(content)
      false
    end

    def status_confirmed?(content)
      false
    end

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

    def confirm_classification(content)
    end

    def ==(other_state)
      self.class == other_state.class
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typo-4.1.1 app/models/content_state/base.rb
typo-4.1 app/models/content_state/base.rb