Class: Micro::Service::Base
- Inherits:
-
Object
- Object
- Micro::Service::Base
- Includes:
- Attributes::Features::ActiveModelValidations
- Defined in:
- lib/micro/service/base.rb,
lib/micro/service/with_validation.rb
Class Method Summary collapse
- .&(service) ⇒ Object
- .>>(service) ⇒ Object
- .__failure_type(arg, type) ⇒ Object
- .__new__(result, arg) ⇒ Object
- .call(options = {}) ⇒ Object
- .to_proc ⇒ Object
Instance Method Summary collapse
Class Method Details
.&(service) ⇒ Object
16 17 18 |
# File 'lib/micro/service/base.rb', line 16 def self.&(service) Pipeline::Safe[self, service] end |
.>>(service) ⇒ Object
12 13 14 |
# File 'lib/micro/service/base.rb', line 12 def self.>>(service) Pipeline[self, service] end |
.__failure_type(arg, type) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/micro/service/base.rb', line 30 def self.__failure_type(arg, type) return type if type != :error case arg when Exception then :exception when Symbol then arg else type end end |
.__new__(result, arg) ⇒ Object
24 25 26 27 28 |
# File 'lib/micro/service/base.rb', line 24 def self.__new__(result, arg) instance = new(arg) instance.__set_result__(result) instance end |
.call(options = {}) ⇒ Object
20 21 22 |
# File 'lib/micro/service/base.rb', line 20 def self.call( = {}) new().call end |
.to_proc ⇒ Object
8 9 10 |
# File 'lib/micro/service/base.rb', line 8 def self.to_proc Proc.new { |arg| call(arg) } end |
Instance Method Details
#__set_result__(result) ⇒ Object
48 49 50 51 52 |
# File 'lib/micro/service/base.rb', line 48 def __set_result__(result) raise Error::InvalidResultInstance unless result.is_a?(Result) raise Error::ResultIsAlreadyDefined if @__result @__result = result end |
#call ⇒ Object
44 45 46 |
# File 'lib/micro/service/base.rb', line 44 def call __call end |
#call! ⇒ Object
40 41 42 |
# File 'lib/micro/service/base.rb', line 40 def call! raise NotImplementedError end |