Module: ABBYY::Cloud::Types
- Defined in:
- lib/abbyy/cloud/types.rb
Constant Summary collapse
- FilledArray =
Gem-specific primitive types
Array.constrained(min_size: 1)
Class Method Summary collapse
-
.register_type(klass, as: nil, constructor: :new) ⇒ Object
Registers new coercible type.
Class Method Details
.register_type(klass, as: nil, constructor: :new) ⇒ Object
Registers new coercible type
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/abbyy/cloud/types.rb', line 8 def self.register_type(klass, as: nil, constructor: :new) type_name = Inflecto.underscore(as || klass.name.split("::").last) definition = Dry::Types::Definition.new(klass).constructor do |value| case value when nil then raise when klass then value else klass.send(constructor, value) end end Dry::Types.register type_name, definition Dry::Types.define_constants self, [type_name] end |