Module: Decidim::SpamDetection::Command

Included in:
BlockSpamUserCommand, ReportSpamUserCommand, SpamUserCommandAdapter
Defined in:
lib/decidim/spam_detection/command.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/decidim/spam_detection/command.rb', line 8

def result
  @result
end

Class Method Details

.prepended(base) ⇒ Object



16
17
18
# File 'lib/decidim/spam_detection/command.rb', line 16

def self.prepended(base)
  base.extend ClassMethods
end

Instance Method Details

#callObject

Raises:

  • (NotImplementedError)


20
21
22
23
24
25
26
27
# File 'lib/decidim/spam_detection/command.rb', line 20

def call
  raise NotImplementedError unless defined?(super)

  @called = true
  @result = super

  self
end

#errorsObject



37
38
39
40
41
# File 'lib/decidim/spam_detection/command.rb', line 37

def errors
  return super if defined?(super)

  @errors ||= Decidim::SpamDetection::CommandErrors.new
end

#failure?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/decidim/spam_detection/command.rb', line 33

def failure?
  called? && errors.any?
end

#success?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/decidim/spam_detection/command.rb', line 29

def success?
  called? && !failure?
end