Class: Base::Operation::Base
- Inherits:
-
Object
- Object
- Base::Operation::Base
- Defined in:
- lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/operation/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**attrs) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(**attrs) ⇒ Base
Returns a new instance of Base.
13 14 15 16 |
# File 'lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/operation/base.rb', line 13 def initialize(**attrs) @attrs = attrs @result = ::Base::Operation::Result.new end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
6 7 8 |
# File 'lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/operation/base.rb', line 6 def result @result end |
Class Method Details
.call(**args) ⇒ Object
8 9 10 11 |
# File 'lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/operation/base.rb', line 8 def self.call(**args) ops = new(**args).tap(&:call) ops.result end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/operation/base.rb', line 18 def call perform!(**@attrs) copy_errors_from_result_to_model @result rescue ActiveRecord::RecordInvalid => e add_errors e.record&.errors copy_errors_from_result_to_model @result end |