Class: Necromancer::ArrayConverters::ObjectToArrayConverter

Inherits:
Converter
  • Object
show all
Defined in:
lib/necromancer/converters/array.rb

Overview

An object that converts an object to an array

Instance Attribute Summary

Attributes inherited from Converter

#config, #convert, #source, #target

Instance Method Summary collapse

Methods inherited from Converter

create, #initialize, #raise_conversion_type

Constructor Details

This class inherits a constructor from Necromancer::Converter

Instance Method Details

#call(value, strict: config.strict) ⇒ Object

Convert an object to an array

Examples:

converter.call({x: 1})   # => [[:x, 1]]


159
160
161
162
163
# File 'lib/necromancer/converters/array.rb', line 159

def call(value, strict: config.strict)
  Array(value)
rescue StandardError
  strict ? raise_conversion_type(value) : value
end