Sha256: 434e0dd18283a2b7aa0d2511936081b0e17072efb003cb935d6ae452280b77cc
Contents?: true
Size: 541 Bytes
Versions: 7
Compression:
Stored size: 541 Bytes
Contents
# frozen_string_literal: true class BCDD::Result class Contract::ForTypes include Contract::Interface attr_reader :allowed_types def initialize(types) @allowed_types = Array(types).map(&:to_sym).to_set.freeze end def type?(type) allowed_types.member?(type) end def type!(type) return type if type?(type) raise Contract::Error::UnexpectedType.build(type: type, allowed_types: allowed_types) end def type_and_value!(data) type!(data.type) nil end end end
Version data entries
7 entries across 7 versions & 1 rubygems