Class: Approval::ExecuteForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, FormNotifiable
Defined in:
app/models/approval/execute_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user:, reason:, request:) ⇒ ExecuteForm

Returns a new instance of ExecuteForm.


8
9
10
11
12
# File 'app/models/approval/execute_form.rb', line 8

def initialize(user:, reason:, request:)
  @user    = user
  @reason  = reason
  @request = request
end

Instance Attribute Details

#reasonObject

Returns the value of attribute reason


6
7
8
# File 'app/models/approval/execute_form.rb', line 6

def reason
  @reason
end

#requestObject

Returns the value of attribute request


6
7
8
# File 'app/models/approval/execute_form.rb', line 6

def request
  @request
end

#userObject

Returns the value of attribute user


6
7
8
# File 'app/models/approval/execute_form.rb', line 6

def user
  @user
end

Instance Method Details

#saveObject


21
22
23
24
25
# File 'app/models/approval/execute_form.rb', line 21

def save
  return false unless valid?

  execute(&:save)
end

#save!Object

Raises:

  • (::ActiveRecord::RecordInvalid)

27
28
29
30
31
# File 'app/models/approval/execute_form.rb', line 27

def save!
  raise ::ActiveRecord::RecordInvalid unless valid?

  execute(&:save!)
end