Class: Viking::Base

Inherits:
Object show all
Defined in:
lib/viking/base.rb

Direct Known Subclasses

Akismet, Defensio

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/viking/base.rb', line 6

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

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/viking/base.rb', line 4

def options
  @options
end

Class Method Details

.loggerObject



48
49
50
# File 'lib/viking/base.rb', line 48

def self.logger
  Viking.logger
end

Instance Method Details

#check_article(options = {}) ⇒ Object



13
14
# File 'lib/viking/base.rb', line 13

def check_article(options = {})
end

#check_comment(options = {}) ⇒ Object



16
17
# File 'lib/viking/base.rb', line 16

def check_comment(options = {})
end

#invalid_options?Boolean

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.

Returns:

  • (Boolean)


61
62
63
# File 'lib/viking/base.rb', line 61

def invalid_options?
  self.options[:api_key].nil? || self.options[:blog].nil?
end

#loggerObject



44
45
46
# File 'lib/viking/base.rb', line 44

def logger
  Viking.logger
end

#mark_as_ham(options = {}) ⇒ Object



22
23
# File 'lib/viking/base.rb', line 22

def mark_as_ham(options = {})
end

#mark_as_spam(options = {}) ⇒ Object



19
20
# File 'lib/viking/base.rb', line 19

def mark_as_spam(options = {})
end

#mark_as_spam_or_ham(is_spam, options = {}) ⇒ Object

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



37
38
39
# File 'lib/viking/base.rb', line 37

def mark_as_spam_or_ham(is_spam, options = {})
  is_spam ? mark_as_spam(options) : mark_as_ham(options)
end

#statsObject



41
42
# File 'lib/viking/base.rb', line 41

def stats
end

#verified?Boolean

Returns:

  • (Boolean)


10
11
# File 'lib/viking/base.rb', line 10

def verified?
end