Class: ClearLogic::Service
- Inherits:
-
Object
- Object
- ClearLogic::Service
- Includes:
- Result, Dry::Transaction
- Defined in:
- lib/clear_logic/service.rb
Constant Summary
Constants included from Result
Class Attribute Summary collapse
-
.context_class ⇒ Object
Returns the value of attribute context_class.
-
.logger_class ⇒ Object
Returns the value of attribute logger_class.
-
.logger_instance ⇒ Object
Returns the value of attribute logger_instance.
-
.logger_options ⇒ Object
Returns the value of attribute logger_options.
Class Method Summary collapse
- .build_context ⇒ Object
- .call(*args) ⇒ Object
- .context(name, type = nil, **options) ⇒ Object
- .inherited(base) ⇒ Object
- .logger(logger_class, log_all: false, log_path: nil) ⇒ Object
Class Attribute Details
.context_class ⇒ Object
Returns the value of attribute context_class.
9 10 11 |
# File 'lib/clear_logic/service.rb', line 9 def context_class @context_class end |
.logger_class ⇒ Object
Returns the value of attribute logger_class.
9 10 11 |
# File 'lib/clear_logic/service.rb', line 9 def logger_class @logger_class end |
.logger_instance ⇒ Object
Returns the value of attribute logger_instance.
9 10 11 |
# File 'lib/clear_logic/service.rb', line 9 def logger_instance @logger_instance end |
.logger_options ⇒ Object
Returns the value of attribute logger_options.
9 10 11 |
# File 'lib/clear_logic/service.rb', line 9 def end |
Class Method Details
.build_context ⇒ Object
16 17 18 |
# File 'lib/clear_logic/service.rb', line 16 def build_context self.context_class = ClearLogic::ContextBuilder.call end |
.call(*args) ⇒ Object
12 13 14 |
# File 'lib/clear_logic/service.rb', line 12 def call(*args) new.call(args) end |
.context(name, type = nil, **options) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/clear_logic/service.rb', line 20 def context(name, type = nil, **) context_class.class_eval do method = .delete(:as) || :option send(method, name, type, **) end end |
.inherited(base) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/clear_logic/service.rb', line 33 def inherited(base) base.class_eval do attr_reader :context build_context logger ClearLogic::Logger::Default step :initialize_context private def initialize_context(args) @context = self.class.context_class.new(*args.flatten) context.service = self success(context) end end end |
.logger(logger_class, log_all: false, log_path: nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/clear_logic/service.rb', line 27 def logger(logger_class, log_all: false, log_path: nil) self. = { log_all: log_all, log_path: log_path } self.logger_class = logger_class self.logger_instance = ClearLogic::Logger::Adapter.new(self).logger end |