Class: ProtectedRecord::UseCase::ChangeRequest::Create
- Inherits:
-
Object
- Object
- ProtectedRecord::UseCase::ChangeRequest::Create
- Includes:
- PayDirt::UseCase
- Defined in:
- lib/protected_record/use_case/change_request/create.rb
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(options) ⇒ Create
constructor
A new instance of Create.
Constructor Details
#initialize(options) ⇒ Create
Returns a new instance of Create.
6 7 8 9 10 11 12 13 |
# File 'lib/protected_record/use_case/change_request/create.rb', line 6 def initialize() = { record_class: ::ProtectedRecord::ChangeRequest::Record }.merge!() if !.has_key?(:record_class) (:record_class, :user, :protected_record, ) validate_state end |
Instance Method Details
#execute! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/protected_record/use_case/change_request/create.rb', line 15 def execute! return PayDirt::Result.new(data: {}, success: true) if !requested_changes.present? initialize_change_request_record if @record.save return PayDirt::Result.new(data: { change_request_record: @record }, success: true) else return PayDirt::Result.new(data: { change_request_record: @record }, success: false) end end |