Class: ApplicationAction

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/application_action.rb,
lib/application_action/version.rb

Constant Summary collapse

VERSION =
'1.0.0'

Instance Method Summary collapse

Instance Method Details

#after_runObject



22
# File 'lib/application_action.rb', line 22

def after_run; end

#runObject



18
19
20
# File 'lib/application_action.rb', line 18

def run
  raise 'You should write your own #run method'
end

#saveObject



4
5
6
7
8
9
10
11
12
# File 'lib/application_action.rb', line 4

def save
  return false unless valid?

  ApplicationRecord.transaction { run }

  after_run

  return true
end

#save!Object



14
15
16
# File 'lib/application_action.rb', line 14

def save!
  raise errors.full_messages.join(', ') unless save
end