Module: CommandTower::Deserializers::Clients::Types
- Defined in:
- app/deserializers/command_tower/deserializers/clients/types.rb
Overview
Composable type processors for response Result validation.
Each raises CommandTower::Clients::Errors::DeserializationError intentionally — no broad rescue.
Defined Under Namespace
Classes: ArrayType, BooleanType, FloatType, IntegerType, ResultInstanceType, StringType, Type, UnionType
Class Method Summary
collapse
Class Method Details
.array(element_type) ⇒ Object
29
30
31
|
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 29
def array(element_type)
ArrayType.new(normalize(element_type))
end
|
.boolean ⇒ Object
21
22
23
|
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 21
def boolean
BooleanType.instance
end
|
.float ⇒ Object
25
26
27
|
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 25
def float
FloatType.instance
end
|
.integer ⇒ Object
13
14
15
|
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 13
def integer
IntegerType.instance
end
|
.normalize(type) ⇒ Object
.string ⇒ Object
17
18
19
|
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 17
def string
StringType.instance
end
|
.union(*member_types) ⇒ Object
33
34
35
36
37
|
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 33
def union(*member_types)
raise ::CommandTower::Clients::Errors::ConfigurationError, "Types.union requires at least one member" if member_types.empty?
UnionType.new(member_types.map { |t| normalize(t) })
end
|