Class: VirtusConvert::Object

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

Instance Method Summary collapse

Constructor Details

#initialize(object, options = {}) ⇒ Object

Returns a new instance of Object.



3
4
5
6
7
8
9
# File 'lib/virtus_convert/object.rb', line 3

def initialize(object, options = {})
  if object.respond_to?(:attributes)
    @object = VirtusConvert.new(object.attributes, options)
  else
    @object = object
  end
end

Instance Method Details

#to_hashObject



11
12
13
# File 'lib/virtus_convert/object.rb', line 11

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