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.



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

def initialize(options)
  self.options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

.loggerObject



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

def self.logger
  Viking.logger
end

Instance Method Details

#check_article(options = {}) ⇒ Object



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

def check_article(options={})
end

#check_comment(options = {}) ⇒ Object



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

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)


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

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

#loggerObject



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

def logger
  Viking.logger
end

#mark_as_ham(options = {}) ⇒ Object



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

def mark_as_ham(options={})
end

#mark_as_spam(options = {}) ⇒ Object



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

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



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

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

#statsObject



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

def stats
end

#verified?Boolean

Returns:

  • (Boolean)


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

def verified?
end