Class: ProtectedRecord::UseCase::Update
- Inherits:
-
Object
- Object
- ProtectedRecord::UseCase::Update
- Includes:
- PayDirt::UseCase
- Defined in:
- lib/protected_record/use_case/update.rb
Direct Known Subclasses
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(options) ⇒ Update
constructor
A new instance of Update.
Constructor Details
#initialize(options) ⇒ Update
Returns a new instance of Update.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/protected_record/use_case/update.rb', line 5 def initialize() # Defaults = { change_request: UseCase::ChangeRequest::Create, change_filter: UseCase::ChangeFilter::Create, change_log: UseCase::ChangeLog::Create }.merge!() (:params, :protected_record, :change_request, :change_log, :change_filter, :user, ) validate_state end |
Instance Method Details
#execute! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/protected_record/use_case/update.rb', line 17 def execute! form_change_request # We are successful if all changes have been applied if !@protected_record.changes.present? return PayDirt::Result.new({ data: { updated: @protected_record, change_request: @change_request_record }, success: true }) else return PayDirt::Result.new({ data: { failed: @protected_record.changes }, success: false }) end end |