Sha256: fae33f4ed790ede58225649dd53b3c0b6c18119f2003cd884fe867a7872c3d5a
Contents?: true
Size: 723 Bytes
Versions: 12
Compression:
Stored size: 723 Bytes
Contents
# frozen_string_literal: true require "dry/monads" module Rubysmith module Configuration module Transformers # Dynamically adds Git email if defined. class GitEmail include Import[:git] include Dry::Monads[:result] def initialize(key = :author_email, **) @key = key super(**) end def call(attributes) = attributes[key] ? Success(attributes) : email_or(attributes) private attr_reader :key def email_or attributes git.get("user.email", nil) .fmap { |value| value ? attributes.merge!(key => value) : attributes } .or { Success attributes } end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems