Sha256: f6d7304f42ead7ea25918bb8159a4ff967201e1cb16b77db09de47cfad9a4341

Contents?: true

Size: 400 Bytes

Versions: 5

Compression:

Stored size: 400 Bytes

Contents

require "contracts"

# Aruba
module Aruba
  # Contracts
  module Contracts
    # Enum
    class Enum < ::Contracts::CallableClass
      private

      attr_reader :vals

      public

      # Create contract
      def initialize(*vals)
        super()
        @vals = vals
      end

      # Check if value is part of array
      def valid?(val)
        vals.include? val
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/aruba-2.2.0/lib/aruba/contracts/enum.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/aruba-2.2.0/lib/aruba/contracts/enum.rb
aruba-2.2.0 lib/aruba/contracts/enum.rb
aruba-2.1.0 lib/aruba/contracts/enum.rb
aruba-2.0.1 lib/aruba/contracts/enum.rb