solnic/virtus — Issue #58: Add coercion for Array and Hash to Virtus::Coercion::Object
Author: dkubb
Created: 2012-01-11 18:55:08+00:00
State: open
Labels: feature

Add `#to_array` and `#to_hash` methods to `Virtus::Coercion::Object` so that they coerce any value that responds to `#to_ary` (and `#to_a`), or `#to_hash` respectively. If the value does not respond to one of those methods then it should be returned directly as-is.

Consider similar coercions for objects into String using `#to_str` and `#to_s`, and Integers using `#to_int` and `#to_i`.