Class: DelayHenka::WhetherSchedule
- Inherits:
-
Object
- Object
- DelayHenka::WhetherSchedule
- Defined in:
- app/services/delay_henka/whether_schedule.rb
Instance Method Summary collapse
- #evaluate_decision(attribute, new_val) ⇒ Object
-
#initialize(record) ⇒ WhetherSchedule
constructor
A new instance of WhetherSchedule.
- #make_decision(attribute, new_val) ⇒ Object
Constructor Details
#initialize(record) ⇒ WhetherSchedule
Returns a new instance of WhetherSchedule.
4 5 6 |
# File 'app/services/delay_henka/whether_schedule.rb', line 4 def initialize(record) @record = record end |
Instance Method Details
#evaluate_decision(attribute, new_val) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'app/services/delay_henka/whether_schedule.rb', line 14 def evaluate_decision(attribute, new_val) Keka.run do old_val = record.public_send(attribute) record.public_send("#{attribute}=", new_val) Keka.err_if! old_val == record.public_send(attribute) Keka.ok_if! record.valid? Keka.err_if! true, record.errors..join(', ') end end |
#make_decision(attribute, new_val) ⇒ Object
8 9 10 11 12 |
# File 'app/services/delay_henka/whether_schedule.rb', line 8 def make_decision(attribute, new_val) evaluate_decision(attribute, new_val).tap do @record.restore_attributes end end |