summaryrefslogtreecommitdiff
path: root/lib/dslkeywords/touch.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-01 23:27:15 +0200
committerPaul Buetow <paul@buetow.org>2026-03-01 23:27:15 +0200
commit1217524955c7ea891ea85cb17dfd13f2b7b1fc3d (patch)
treef1ed556cc9308ed153c32ce7a9f812af40742a34 /lib/dslkeywords/touch.rb
parentfba26f6d9f18600dc313b6d4ade65d536e9762e9 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'lib/dslkeywords/touch.rb')
-rw-r--r--lib/dslkeywords/touch.rb8
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/dslkeywords/touch.rb b/lib/dslkeywords/touch.rb
index 27e691b..13d63f7 100644
--- a/lib/dslkeywords/touch.rb
+++ b/lib/dslkeywords/touch.rb
@@ -26,13 +26,7 @@ module RCM
class DSL
def touch(file_path = nil, &block)
- return :touch if file_path.nil?
- return unless @conds_met
-
- t = Touch.new(file_path)
- t.instance_eval(&block) if block
- self << t
- t
+ register_keyword(Touch, :touch, file_path) { |t| t.instance_eval(&block) if block }
end
end
end