Sha256: 239a77e370881fc2e3f468f98c3f7b51650e00d9ca89f6cb0d657b83d5f85a84

Contents?: true

Size: 796 Bytes

Versions: 13

Compression:

Stored size: 796 Bytes

Contents

module Eco
  module API
    class UseCases
      # Core class of UseCases. It basically defines and manages allowed `types`
      class BaseCase

        class InvalidType < Exception
          def initialize(msg = nil, type:, types:)
            msg ||= "Invalid type."
            msg = "Given type '#{type}'. Valid types: #{types}"
            super(msg)
          end
        end

        @types = [:import, :filter, :transform, :sync, :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

13 entries across 13 versions & 1 rubygems

Version Path
eco-helpers-1.2.2 lib/eco/api/usecases/base_case.rb
eco-helpers-1.2.1 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.8 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.7 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.6 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.5 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.4 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.3 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.2 lib/eco/api/usecases/base_case.rb
eco-helpers-1.1.1 lib/eco/api/usecases/base_case.rb
eco-helpers-1.0.14 lib/eco/api/usecases/base_case.rb
eco-helpers-1.0.13 lib/eco/api/usecases/base_case.rb
eco-helpers-1.0.12 lib/eco/api/usecases/base_case.rb