Module: Types
- Defined in:
- lib/prolog/dry_types/uuid.rb,
lib/prolog/dry_types/error_array.rb,
lib/prolog/dry_types/time_or_now.rb,
lib/prolog/dry_types/integer_range.rb,
lib/prolog/dry_types/include_module.rb
Overview
‘Types` as a top-level namespace module seems to be a `dry-types` convention.
Constant Summary collapse
- UUID_FORMAT =
/\A\h{8}(-\h{4}){3}\-\h{12}\z/
- UUID =
Types::Strict::String.default { ::UUID.generate } .constrained(format: UUID_FORMAT)
- ErrorArray =
Types::Strict::Array.member(Types::Strict::Hash)
- TimeOrNow =
Types::Strict::Time.default { ::Time.now }
- IntegerRange =
The original version of this type treated initialisation with an integer value of zero as invalid, setting the initialised range to (-1..-1). On reflection, this makes little sense as a general-purpose behaviour, as it is highly likely to surprise casual users.
Range.constructor do |value| if value.respond_to?(:minmax) # Enumerable; eg, Range or Array value.min..value.max else # it *better* be an Integer 0..value.to_i end end