lib/data_model/builtin/boolean.rb in data_model-0.4.0 vs lib/data_model/builtin/boolean.rb in data_model-0.5.0

- old
+ new

@@ -1,21 +1,24 @@ -# typed: strict - module DataModel + # Boolean type class Builtin::Boolean < Type include Errors - class Arguments < T::Struct - prop :optional, T::Boolean, default: false + # Arguments for the boolean type + class Arguments < Struct + prop :optional, :boolean, default: false end - sig { override.params(val: Object, coerce: T::Boolean).returns(TTypeResult) } + # read a value, and validate it + # @param val [Object] the value to read + # @param coerce [Boolean] whether to coerce the value + # @return [Array(Object, Error)] the result of reading the value def read(val, coerce: false) err = Error.new if val.nil? - err.add(missing_error(DataModel::Boolean)) + err.add(missing_error(type_name)) return [val, err] end if coerce case val @@ -25,10 +28,10 @@ val = false end end if !val.is_a?(TrueClass) && !val.is_a?(FalseClass) - err.add(type_error(Boolean, val)) + err.add(type_error(type_name, val)) return [val, err] end return [val, err] end