Class: CommandMapper::Types::KeyValueList

Inherits:
List
  • Object
show all
Defined in:
lib/command_mapper/types/key_value_list.rb

Overview

Represents a list of key=value pairs.

Instance Attribute Summary

Attributes inherited from List

#separator, #type

Instance Method Summary collapse

Methods inherited from List

#allow_empty?, #validate

Methods inherited from Type

#validate

Constructor Details

#initialize(separator: ',', key_value_separator: '=', **kwargs) ⇒ KeyValueList

Initializes the key-value list.

Parameters:



23
24
25
26
27
28
# File 'lib/command_mapper/types/key_value_list.rb', line 23

def initialize(separator: ',', key_value_separator: '=', **kwargs)
  super(
    type:      KeyValue.new(separator: key_value_separator, **kwargs),
    separator: separator
  )
end

Instance Method Details

#format(value) ⇒ String

Formats the value.

Parameters:

  • The list of key-value pairs to format.

Returns:

  • The formatted key-value list.

API:

  • semipublic



41
42
43
# File 'lib/command_mapper/types/key_value_list.rb', line 41

def format(value)
  super(Array(value).map(&@type.method(:format)))
end