Class: Batch::RequestFailAndRemover

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/batch/request_fail_and_remover.rb

Overview

Handles failure of requests or their removal from the batch via BatchesController#fail_items

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentObject

Returns the value of attribute comment


8
9
10
# File 'app/models/batch/request_fail_and_remover.rb', line 8

def comment
  @comment
end

#reasonObject

Returns the value of attribute reason


8
9
10
# File 'app/models/batch/request_fail_and_remover.rb', line 8

def reason
  @reason
end

#requested_fail=(value) ⇒ Object

Sets the attribute requested_fail


9
10
11
# File 'app/models/batch/request_fail_and_remover.rb', line 9

def requested_fail=(value)
  @requested_fail = value
end

#requested_remove=(value) ⇒ Object

Sets the attribute requested_remove


9
10
11
# File 'app/models/batch/request_fail_and_remover.rb', line 9

def requested_remove=(value)
  @requested_remove = value
end

Instance Method Details

#failure=(failure_hash) ⇒ Object


29
30
31
32
33
# File 'app/models/batch/request_fail_and_remover.rb', line 29

def failure=(failure_hash)
  @reason = failure_hash[:reason]
  @comment = failure_hash[:comment]
  @fail_but_charge = failure_hash[:fail_but_charge]
end

#id=(batch_id) ⇒ Object

ID is the batch id passed in from the controller


36
37
38
# File 'app/models/batch/request_fail_and_remover.rb', line 36

def id=(batch_id)
  @batch = Batch.find(batch_id)
end

#noticeObject


25
26
27
# File 'app/models/batch/request_fail_and_remover.rb', line 25

def notice
  @notice ||= []
end

#saveObject


17
18
19
20
21
22
23
# File 'app/models/batch/request_fail_and_remover.rb', line 17

def save
  return false unless valid?

  fail_requests if requested_fail.present?
  remove_requests if requested_remove.present?
  true
end