Module: ActForm::Runnable

Extended by:
ActiveSupport::Concern
Included in:
Command
Defined in:
lib/act_form/runnable.rb

Overview

Define runnable behaivor for form object.

Instance Method Summary collapse

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/act_form/runnable.rb', line 58

def failure?
  !success?
end

#has_errors?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


30
31
32
# File 'lib/act_form/runnable.rb', line 30

def has_errors? # rubocop:disable Naming/PredicateName
  !errors.empty?
end

#performObject



52
# File 'lib/act_form/runnable.rb', line 52

def perform; end

#runObject



34
35
36
37
38
39
40
# File 'lib/act_form/runnable.rb', line 34

def run
  if valid?
    @result    = perform
    @performed = true
  end
  self
end

#run!Object



42
43
44
45
46
47
48
49
50
# File 'lib/act_form/runnable.rb', line 42

def run!
  if valid? # rubocop:disable Style/GuardClause
    @result    = perform
    @performed = true
    result
  else
    raise RunError, 'Verification failed'
  end
end

#success?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/act_form/runnable.rb', line 54

def success?
  !has_errors? && !!@performed
end