Class: VirtusConvert::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/virtus_convert/converter.rb

Instance Method Summary collapse

Constructor Details

#initialize(unknown, options = {}) ⇒ Converter

Returns a new instance of Converter.



9
10
11
12
13
# File 'lib/virtus_convert/converter.rb', line 9

def initialize(unknown, options = {})
  @root = VirtusConvert::Hash.new(unknown, options) if unknown.is_a? ::Hash
  @root ||= VirtusConvert::Array.new(unknown, options) if unknown.is_a? ::Array
  @root ||= VirtusConvert::Object.new(unknown, options)
end

Instance Method Details

#to_hashObject



15
16
17
# File 'lib/virtus_convert/converter.rb', line 15

def to_hash
  @root.respond_to?(:to_hash) ? @root.to_hash : @root
end