class Interage::ApplicationService
Attributes
errors[R]
Public Class Methods
call(**args)
click to toggle source
Call your service
Example:
Foo.call(arg1: 1, arg2: 2)
Arguments:
args: (Hash)
Return:
perform's return
# File lib/interage/application_service.rb, line 17 def self.call(**args) new(args).perform end
new(args = {})
click to toggle source
# File lib/interage/application_service.rb, line 21 def initialize(args = {}) args.each { |key, value| set_private_ivar(key, value) } end
Public Instance Methods
perform()
click to toggle source
Implement this method to run your service
# File lib/interage/application_service.rb, line 26 def perform raise NotImplementedError, "Please implement 'perform' method in your #{self.class.name}" end
success?()
click to toggle source
# File lib/interage/application_service.rb, line 31 def success? errors.blank? end
Private Instance Methods
set_private_ivar(key, value)
click to toggle source
# File lib/interage/application_service.rb, line 37 def set_private_ivar(key, value) instance_variable_set("@#{key}", value) self.class.class_eval do private attr_reader key.to_sym end end