From 13657c3c13dc62d6aba6e0633fc7f99e44170c06 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 19 Feb 2025 00:00:06 +0200 Subject: nicer --- lib/dslkeywords/file.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'lib/dslkeywords/file.rb') diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb index e17cfeb..eeff82f 100644 --- a/lib/dslkeywords/file.rb +++ b/lib/dslkeywords/file.rb @@ -41,20 +41,20 @@ module RCM def line(line) = @ensure_line = line def path(file_path = nil) = file_path.nil? ? @file_path : @file_path = file_path - # TODO: Replace :is with current method name dynamically - def is(what) = @is = validate_op(:is, what, present, absent) - def present = :present - def absent = :absent - - def manage(what) = @manage_directory = validate_op(:is, what, directory) == directory - def directory = :directory - - def without(what) = @without_backup = validate_op(:without, what, backup) == backup - def backup = :backup + def is(what) = @is = validate_op(__method__, what, present, absent) + def manage(what) = @manage_directory = validate_op(__method__, what, directory) == directory + def without(what) = @without_backup = validate_op(__method__, what, backup) == backup + def from(what) = @from = validate_op(__method__, what, sourcefile, template) + + def method_missing(method_name, *args) + if %i[present absent directory backup sourcefile template].include?(method_name) + method_name + else + super + end + end - def from(what) = @from = validate_op(:from, what, sourcefile, template) - def sourcefile = :sourcefile - def template = :template + def respond_to_missing? = true def evaluate! return unless super -- cgit v1.2.3