Class: Approval::RespondForm::Base

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

Direct Known Subclasses

Approve, ApproveWithExecute, Cancel, Reject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Base.


9
10
11
12
13
# File 'app/models/approval/respond_form/base.rb', line 9

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

Instance Attribute Details

#reasonObject

Returns the value of attribute reason


7
8
9
# File 'app/models/approval/respond_form/base.rb', line 7

def reason
  @reason
end

#requestObject

Returns the value of attribute request


7
8
9
# File 'app/models/approval/respond_form/base.rb', line 7

def request
  @request
end

#userObject

Returns the value of attribute user


7
8
9
# File 'app/models/approval/respond_form/base.rb', line 7

def user
  @user
end

Instance Method Details

#saveObject


19
20
21
22
23
# File 'app/models/approval/respond_form/base.rb', line 19

def save
  return false unless valid?

  prepare(&:save)
end

#save!Object

Raises:

  • (::ActiveRecord::RecordInvalid)

25
26
27
28
29
# File 'app/models/approval/respond_form/base.rb', line 25

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

  prepare(&:save!)
end