Sha256: 53e126ddafec8fd1083bbdbb77502d3955b96c6aeb226160d4bc86d032f57d1a

Contents?: true

Size: 365 Bytes

Versions: 2

Compression:

Stored size: 365 Bytes

Contents

# frozen_string_literal: true

module Yasd
  class Mapper
    def initialize(filepath)
      @mappings = filepath ? YAML.load_file(filepath) : {}
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yasd-0.1.1 lib/yasd/mapper.rb
yasd-0.1.0 lib/yasd/mapper.rb