Module: ServiceOperation::Base
- Included in:
- RackMountable
- Defined in:
- lib/service_operation/base.rb
Overview
Base
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(context = {}) ⇒ Object
Instance Methods.
- #run ⇒ Object
- #run! ⇒ Object
- #skip ⇒ Object
- #skip! ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/service_operation/base.rb', line 7 def self.included(base) base.class_eval do extend ClassMethods include Delay include ErrorHandling include Hooks include Params include Validations attr_reader :context end end |
Instance Method Details
#call ⇒ Object
51 52 53 |
# File 'lib/service_operation/base.rb', line 51 def call nil end |
#initialize(context = {}) ⇒ Object
Instance Methods
47 48 49 |
# File 'lib/service_operation/base.rb', line 47 def initialize(context = {}) @context = Context.build(context) end |
#run ⇒ Object
55 56 57 58 59 |
# File 'lib/service_operation/base.rb', line 55 def run run! rescue Failure nil end |
#run! ⇒ Object
61 62 63 |
# File 'lib/service_operation/base.rb', line 61 def run! with_hooks { fail_if_errors! || skip || call } && true end |
#skip ⇒ Object
65 66 67 |
# File 'lib/service_operation/base.rb', line 65 def skip context.skip || false end |
#skip! ⇒ Object
69 70 71 |
# File 'lib/service_operation/base.rb', line 69 def skip! context.skip = true end |