Class: Interage::ApplicationService
- Inherits:
-
Object
- Object
- Interage::ApplicationService
- Defined in:
- lib/interage/application_service.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Class Method Summary collapse
-
.call(**args) ⇒ Object
Call your service.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ ApplicationService
constructor
A new instance of ApplicationService.
-
#perform ⇒ Object
Implement this method to run your service.
- #success? ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ ApplicationService
Returns a new instance of ApplicationService.
21 22 23 |
# File 'lib/interage/application_service.rb', line 21 def initialize(args = {}) args.each { |key, value| set_private_ivar(key, value) } end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/interage/application_service.rb', line 5 def errors @errors end |
Class Method Details
.call(**args) ⇒ Object
Call your service
Example:
Foo.call(arg1: 1, arg2: 2)
Arguments:
args: (Hash)
Return:
perform's return
17 18 19 |
# File 'lib/interage/application_service.rb', line 17 def self.call(**args) new(args).perform end |
Instance Method Details
#perform ⇒ Object
Implement this method to run your service
26 27 28 29 |
# File 'lib/interage/application_service.rb', line 26 def perform raise NotImplementedError, "Please implement 'perform' method in your #{self.class.name}" end |
#success? ⇒ Boolean
31 32 33 |
# File 'lib/interage/application_service.rb', line 31 def success? errors.blank? end |