Class: Hmibo::Base
- Inherits:
-
Object
- Object
- Hmibo::Base
- Defined in:
- lib/hmibo/base.rb
Overview
Base service class that provides common patterns for service objects Inspired by DetectionTek patterns - simple, dependency-free Ruby classes
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#errors ⇒ Object
Returns the value of attribute errors.
Class Method Summary collapse
-
.call(*args, **kwargs) ⇒ Object
Class method for convenient service execution.
Instance Method Summary collapse
-
#call ⇒ Object
Main entry point for service execution.
- #errors? ⇒ Boolean
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 |
# File 'lib/hmibo/base.rb', line 9 def initialize(*args) @errors = [] @data = nil setup(*args) if respond_to?(:setup, true) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/hmibo/base.rb', line 7 def data @data end |
#errors ⇒ Object
Returns the value of attribute errors.
7 8 9 |
# File 'lib/hmibo/base.rb', line 7 def errors @errors end |
Class Method Details
.call(*args, **kwargs) ⇒ Object
Class method for convenient service execution
24 25 26 |
# File 'lib/hmibo/base.rb', line 24 def self.call(*args, **kwargs) new(*args, **kwargs).call end |
Instance Method Details
#call ⇒ Object
Main entry point for service execution
16 17 18 19 20 21 |
# File 'lib/hmibo/base.rb', line 16 def call perform rescue StandardError => e handle_error(e) self end |
#errors? ⇒ Boolean
28 29 30 |
# File 'lib/hmibo/base.rb', line 28 def errors? !@errors.empty? end |