leifg/morfo — pull request #3 by leifg (2014-01-12 22:44:00+00:00)
Title: Convert to declarative syntax

The current syntax for mapping is imperative, meaning the class takes concrete instructions what to do with every value of the hash.

When converting from hashes to hashes, a more declarative syntax would be useful:

class TitleMorfer < Morfo::Base
field(:tv_show_title, from: :title)
end

transformations and calculations can easily achieved with procs:

class TitleMorfer < Morfo::Base
field(:title_with_prefix, from: :title, transformation: proc{|value| "TV Show: #{value}" })
field(:title_with_channel, calculation: proc{|row| "row[:title] (row[:channel]: })
end