Class: CommandTower::Deserializers::Clients::Types::UnionType
- Defined in:
- app/deserializers/command_tower/deserializers/clients/types.rb
Instance Method Summary collapse
- #call(value, path:) ⇒ Object
- #expected_label ⇒ Object
-
#initialize(member_types) ⇒ UnionType
constructor
A new instance of UnionType.
Constructor Details
#initialize(member_types) ⇒ UnionType
Returns a new instance of UnionType.
195 196 197 |
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 195 def initialize(member_types) @member_types = member_types end |
Instance Method Details
#call(value, path:) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 199 def call(value, path:) @member_types.each do |member| begin return member.call(value, path: path) rescue ::CommandTower::Clients::Errors::DeserializationError next end end labels = @member_types.map(&:expected_label).join(" | ") reject!(path, value, labels, "value matched no union member") end |
#expected_label ⇒ Object
212 213 214 |
# File 'app/deserializers/command_tower/deserializers/clients/types.rb', line 212 def expected_label @member_types.map(&:expected_label).join(" | ") end |