Sha256: 53359fe60a7c1d0b25889af11ace0722302b172ff8f5a92928a497fc518055ea

Contents?: true

Size: 564 Bytes

Versions: 9

Compression:

Stored size: 564 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.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

9 entries across 9 versions & 1 rubygems

Version Path
u-service-0.9.0 lib/micro/service/base.rb
u-service-0.8.0 lib/micro/service/base.rb
u-service-0.7.0 lib/micro/service/base.rb
u-service-0.6.0 lib/micro/service/base.rb
u-service-0.5.0 lib/micro/service/base.rb
u-service-0.4.0 lib/micro/service/base.rb
u-service-0.3.0 lib/micro/service/base.rb
u-service-0.2.0 lib/micro/service/base.rb
u-service-0.1.0 lib/micro/service/base.rb