Sha256: 6282f66c3477c561185c81c3f6bb1bbbf0643ecfbc7a5e49b282f42b4534b8a1

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

# frozen_string_literal: true

module Micro
  module Service
    class Base
      include Micro::Attributes.without(:strict_initialize)
      include Result::Helpers

      INVALID_RESULT = '#call! must return a Micro::Service::Result instance'.freeze

      def self.>>(service)
        Micro::Service::Pipeline[self, service]
      end

      def self.call(options = {})
        new(options).call
      end

      def call!
        raise NotImplementedError
      end

      def call
        result = call!
        return result if result.is_a?(Service::Result)
        raise TypeError, self.class.name + INVALID_RESULT
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
u-service-0.11.0 lib/micro/service/base.rb
u-service-0.10.0 lib/micro/service/base.rb