From 1217524955c7ea891ea85cb17dfd13f2b7b1fc3d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 1 Mar 2026 23:27:15 +0200 Subject: refactor: extract register_keyword helper to eliminate 4x DSL duplication Each of the file/symlink/touch/directory DSL methods repeated the same four-step pattern: nil-path identity return, @conds_met guard, create- configure-register, return object. Add a private register_keyword helper to DSL in dsl.rb and collapse each method to a one-liner. No behaviour changed; all 29 tests continue to pass. Co-Authored-By: Claude Sonnet 4.6 --- lib/dslkeywords/symlink.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib/dslkeywords/symlink.rb') diff --git a/lib/dslkeywords/symlink.rb b/lib/dslkeywords/symlink.rb index 160da6f..053e83d 100644 --- a/lib/dslkeywords/symlink.rb +++ b/lib/dslkeywords/symlink.rb @@ -22,13 +22,7 @@ module RCM class DSL def symlink(file_path = nil, &block) - return :symlink if file_path.nil? - return unless @conds_met - - s = Symlink.new(file_path) - s.content(s.instance_eval(&block)) - self << s - s + register_keyword(Symlink, :symlink, file_path) { |s| s.content(s.instance_eval(&block)) } end end end -- cgit v1.2.3