Module: ReciteCSV::Header::Definition

Defined in:
lib/recite_csv/header/definition.rb

Defined Under Namespace

Classes: Array, Base, Hash

Constant Summary collapse

DEFINITIONS =
{
  ::Hash => Hash,
  ::Array => Array
}.freeze

Class Method Summary collapse

Class Method Details

.dispatch(header_definition) ⇒ Object

Raises:

  • (::ArgumentError)


73
74
75
76
77
78
79
80
# File 'lib/recite_csv/header/definition.rb', line 73

def dispatch(header_definition)
  _, definition_class = DEFINITIONS.find do |klass, _|
    header_definition.is_a? klass
  end
  raise ::ArgumentError, "Unexpected header definition type" unless definition_class

  definition_class.new(header_definition)
end