intridea/hashie — pull request #44 by fabn (2012-04-16 23:06:45+00:00)
Title: Trash property options to transform values using proc or lambdas

I've added some options to the Trash class to transform `:from` properties using a lambda. This could be very useful when reading data from external API's to change not just the name of a field but also its content.

In the same way I've added another option to transform values without using the `:from` option.

In this way one could do this kind of things

class Result < Hashie::Trash
property :id, :transform_with => { |v| v.to_i }
property :created_at, :from => :creation_date, :with => { |v| DateTime.parse(v) }
end

and so on.

I've also added an error check for the property option to avoid stack error when `:from` option has the same value of the property name.

Hope this will be helpful.