class DAP::Relation::OneOf

Indicates a property is expected to be one of a set of types

Attributes

key[R]

The name of the key property.

types[R]

The allowed key property values and expected types.

Public Class Methods

new(types) click to toggle source

@param types [Hash<Symbol, Class>] the allowed key property values and expected types

# File lib/dap/relation.rb, line 29
def initialize(types)
  types.values.each { |k| DAP::Relation.supported!(k) }
  @types = types
end

Public Instance Methods

[]=(k, v) click to toggle source

Sets the expected type for a specified value of the key property. @param k [Symbol] the specified value @param v [Class] the expected type

# File lib/dap/relation.rb, line 45
def []=(k, v)
  @types[k] = v
end
with(key) click to toggle source

Specifies the key property that is used to determine which type is selected. @param key [Symbol] the name of the key property

# File lib/dap/relation.rb, line 36
def with(key)
  o = dup
  o.instance_eval { @key = key }
  o
end