Sha256: 5b6429333182d27e9224f66898beeba6142cf73e0a28370b2989fa2498be9650

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

module TheViking
  class Base

    attr_accessor :options

    def initialize(options = {})
      self.options = options
    end

    def verified?
    end

    def check_article(options = {})
    end

    def check_comment(options = {})
    end

    def mark_as_spam(options = {})
    end

    def mark_as_ham(options = {})
    end

    # Automatically determines whether to mark as spam or ham depending on a
    # boolean switch, +is_spam+. The post will be marked as spam when
    # +is_spam+ is +true+. The post will be marked as ham if +is_spam+ is
    # +false+.
    #
    # ==== Arguments
    # +is_spam+ <Boolean>::
    #   determines whether to mark a post as spam or ham -- spam when true,
    #   ham when false
    #
    # +options+ <Hash>::
    #   any options either +mark_as_spam+ or +mark_as_ham+ accepts
    def mark_as_spam_or_ham(is_spam, options = {})
      is_spam ? mark_as_spam(options) : mark_as_ham(options)
    end

    def stats
    end

    def logger
      TheViking.logger
    end

    def self.logger
      TheViking.logger
    end

    # Checks to ensure that the minimum number of +options+ have been provided
    # to make a call to the spam protection service.
    #
    # Required options include:
    # * +api_key+
    # * +blog+
    #
    # See the module for your desired spam protection service for details on
    # the format of these options.
    def invalid_options?
      self.options[:api_key].nil? || self.options[:blog].nil?
    end

    protected

    def log_request(url, data, response)
      return unless logger
      logger.info("[#{self.class.name}] POST '%s' with %s" % [url, data])
      logger.debug(">> #{response.body.inspect}")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
the_viking-1.0.0 lib/the_viking/base.rb