Module: Crossbeam
- Defined in:
- lib/crossbeam.rb,
lib/crossbeam/error.rb,
lib/crossbeam/errors.rb,
lib/crossbeam/output.rb,
lib/crossbeam/result.rb,
lib/crossbeam/version.rb,
lib/crossbeam/callbacks.rb
Overview
Crossbeam module to include with your service classes
Defined Under Namespace
Modules: Callbacks, ClassMethods, Output Classes: ArguementError, Error, Errors, Failure, NotImplementedError, Result, UndefinedMethod
Constant Summary collapse
- VERSION =
'0.1.2'
Class Method Summary collapse
-
.included(base) ⇒ void
Used to include/extend modules into the current class.
Instance Method Summary collapse
-
#errors ⇒ Hash
Used to return a list of errors for the current call.
-
#fail!(error) ⇒ void
Force the job to raise an exception and stop the rest of the service call.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Used to include/extend modules into the current class
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/crossbeam.rb', line 23 def self.included(base) base.class_eval do include(ActiveModel::Validations) # Used to add validation errors to a class extend(Dry::Initializer) # Used to allow for easy attribute initializations extend(ClassMethods) # Class methods used to initialize the service call include(Output) include(Callbacks) # Callbacks that get called before/after `.call` is referenced # Holds the service call results and current class call for Crossbeam Instance attr_reader :result, :klass end end |
Instance Method Details
#errors ⇒ Hash
Used to return a list of errors for the current call
103 104 105 106 107 |
# File 'lib/crossbeam.rb', line 103 def errors return {} unless @result @result.errors end |