Class: VirtusConvert::Converter
- Inherits:
-
Object
- Object
- VirtusConvert::Converter
- Defined in:
- lib/virtus_convert/converter.rb
Instance Method Summary collapse
-
#initialize(unknown, options = {}) ⇒ Converter
constructor
A new instance of Converter.
- #to_hash ⇒ Object
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, = {}) @root = VirtusConvert::Hash.new(unknown, ) if unknown.is_a? ::Hash @root ||= VirtusConvert::Array.new(unknown, ) if unknown.is_a? ::Array @root ||= VirtusConvert::Object.new(unknown, ) end |
Instance Method Details
#to_hash ⇒ Object
15 16 17 |
# File 'lib/virtus_convert/converter.rb', line 15 def to_hash @root.respond_to?(:to_hash) ? @root.to_hash : @root end |