Sha256: 2860e2a48c80f408e086424152839fa115f17e7baf1a69b968ae2cc8971ef22c

Contents?: true

Size: 941 Bytes

Versions: 27

Compression:

Stored size: 941 Bytes

Contents

module Eco
  module API
    class UseCases
      # Core class of UseCases. It basically defines and manages allowed `types`
      class BaseCase
        class InvalidType < StandardError
          def initialize(msg = nil, type:, types:)
            msg ||= "Invalid type. "
            msg  << "Given type '#{type}'. Valid types: #{types}"
            super(msg)
          end
        end

        extend Eco::API::Common::ClassHelpers

        @types = %i[
          import
          filter
          transform
          sync
          error_handler
          export
          other
        ]

        class << self
          attr_reader :types

          def valid_type?(type)
            types.include?(type)
          end

          def validate_type(type)
            raise InvalidType.new(type: type, types: types) unless valid_type?(type)
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.20 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.19 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.18 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.17 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.16 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.15 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.14 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.13 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.12 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.11 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.10 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.9 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.8 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.7 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.6 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.5 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.4 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.3 lib/eco/api/usecases/base_case.rb
eco-helpers-3.0.2 lib/eco/api/usecases/base_case.rb