Module: Mu::Action
- Defined in:
- lib/mu/action.rb,
lib/mu/action/version.rb
Overview
Provides an interactor pattern implementation with hooks, metadata tracking, and result wrapping.
Defined Under Namespace
Modules: ClassMethods, HookPropagator, Initializer, MetaPropAdder Classes: Failure, FailureError, Result, Success
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Instance Method Summary collapse
- #Failure(error, **meta) ⇒ Object
-
#run ⇒ Object
rubocop:enable Naming/MethodName.
- #run! ⇒ Object
-
#Success(value) ⇒ Object
rubocop:disable Naming/MethodName.
Class Method Details
.included(base) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mu/action.rb', line 10 def self.included(base) base.class_eval do extend Literal::Properties extend ClassMethods include Initializer singleton_class.prepend(MetaPropAdder) singleton_class.prepend(HookPropagator) attr_reader :meta end end |
Instance Method Details
#Failure(error, **meta) ⇒ Object
147 148 |
# File 'lib/mu/action.rb', line 147 def Failure(error, **) = raise FailureError.new(error, meta:) # rubocop:enable Naming/MethodName |
#run ⇒ Object
rubocop:enable Naming/MethodName
150 151 152 153 154 |
# File 'lib/mu/action.rb', line 150 def run run! rescue FailureError => e Failure.new(e.error, meta: { failure_error: e, **, **e. }) end |
#run! ⇒ Object
156 157 158 |
# File 'lib/mu/action.rb', line 156 def run! with_hooks { call } end |
#Success(value) ⇒ Object
rubocop:disable Naming/MethodName
146 |
# File 'lib/mu/action.rb', line 146 def Success(value) = self.class.const_get(:Success).new(value, meta:) |