Sha256: 1d8e926215017e5d51e10c7f53050fdd0e85198c2b3d01d8f9c70c561e978e1b

Contents?: true

Size: 547 Bytes

Versions: 2

Compression:

Stored size: 547 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"

module Rubysmith
  module Configuration
    # Sets target root which defaults to current directory when key is missing.
    module Transformers
      include Dry::Monads[:result]

      TargetRoot = lambda do |attributes, key = :target_root, path: Pathname.pwd|
        attributes.fetch(:target_root) { path }
                  .then { |value| attributes.merge! key => value }
                  .then { |updated_attributes| Dry::Monads::Success updated_attributes }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysmith-6.10.0 lib/rubysmith/configuration/transformers/target_root.rb
rubysmith-6.9.0 lib/rubysmith/configuration/transformers/target_root.rb