Module: UseCasePattern::Base
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/use_case_pattern/base.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Did the use case have any errors?.
-
#perform ⇒ Object
Implement all the steps required to complete this use case.
- #perform! ⇒ Object
-
#success? ⇒ Boolean
Did the use case performed its task without errors?.
Instance Method Details
#failure? ⇒ Boolean
Did the use case have any errors?
46 47 48 |
# File 'lib/use_case_pattern/base.rb', line 46 def failure? errors.any? end |
#perform ⇒ Object
Implement all the steps required to complete this use case
26 27 28 |
# File 'lib/use_case_pattern/base.rb', line 26 def perform raise NotImplementedError end |
#perform! ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/use_case_pattern/base.rb', line 30 def perform! if valid? perform end if failure? raise_validation_error end end |
#success? ⇒ Boolean
Did the use case performed its task without errors?
41 42 43 |
# File 'lib/use_case_pattern/base.rb', line 41 def success? errors.none? end |