summaryrefslogtreecommitdiff
path: root/lib/dslkeywords
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-02-19 11:41:05 +0200
committerPaul Buetow <paul@buetow.org>2025-02-19 11:41:05 +0200
commit967288d15793d43bafffda4bb18043262ada1a40 (patch)
tree8422a8f0c5b769c0035b1e83a01235b7093229fc /lib/dslkeywords
parent5d866242fd0816c0999cfe66d56c15e1d7313971 (diff)
refactor
Diffstat (limited to 'lib/dslkeywords')
-rw-r--r--lib/dslkeywords/file.rb19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/dslkeywords/file.rb b/lib/dslkeywords/file.rb
index 788ff4f..7de7492 100644
--- a/lib/dslkeywords/file.rb
+++ b/lib/dslkeywords/file.rb
@@ -43,10 +43,10 @@ module RCM
def line(line) = @ensure_line = line
def path(file_path = nil) = file_path.nil? ? @file_path : @file_path = file_path
- def is(what) = @is = validate(__method__, what, :present, :absent)
- def manage(what) = @manage_directory = validate(__method__, what, :directory) == :directory
- def without(what) = @without_backup = validate(__method__, what, :backup) == :backup
- def from(what) = @from = validate(__method__, what, :sourcefile, :template)
+ def is(what) = @is = validate(__method__, what.to_sym, :present, :absent, :symlink)
+ def manage(what) = @manage_directory = validate(__method__, what.to_sym, :directory) == :directory
+ def without(what) = @without_backup = validate(__method__, what.to_sym, :backup) == :backup
+ def from(what) = @from = validate(__method__, what.to_sym, :sourcefile, :template)
def evaluate!
return unless super
@@ -59,14 +59,11 @@ module RCM
private
# Validate whether we can use this up in this context or not
- def validate(matter, what, *valids)
- what = what.to_sym
- unless valids.include?(what)
- raise UnsupportedOperation,
- "Unsupported '#{matter}' operation #{what} (#{what.class})"
- end
+ def validate(method, what, *valids)
+ return what if valids.include?(what)
- what
+ raise UnsupportedOperation,
+ "Unsupported '#{method}' operation #{what} (#{what.class})"
end
def evaluate_ensure_line!