class Yasd::Mapper
Public Class Methods
new(filepath)
click to toggle source
# File lib/yasd/mapper.rb, line 5 def initialize(filepath) @mappings = filepath ? YAML.load_file(filepath) : {} end
Public Instance Methods
call(data)
click to toggle source
# File lib/yasd/mapper.rb, line 9 def call(data) data.each_with_object({}) do |(field, value), new_object| new_key = @mappings[field] || field new_object[new_key] = value new_object end end