diff options
| author | Paul Buetow <paul@buetow.org> | 2025-02-15 10:22:50 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-02-15 10:22:50 +0200 |
| commit | 8729aafe5bca25d0f7e94bd3c7ee1e0f60f99035 (patch) | |
| tree | 2a88726109ad3482f79937d0b87f6fc05be43c6c /lib/dslkeywords/resource.rb | |
| parent | 6879b03b2735b082b913ab17e63857f464f53c93 (diff) | |
add depends_on syntax
Diffstat (limited to 'lib/dslkeywords/resource.rb')
| -rw-r--r-- | lib/dslkeywords/resource.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/dslkeywords/resource.rb b/lib/dslkeywords/resource.rb new file mode 100644 index 0000000..6612428 --- /dev/null +++ b/lib/dslkeywords/resource.rb @@ -0,0 +1,31 @@ +require_relative 'keyword' + +module RCM + # To track recource dependencies + module Dependency + # Only to have the resourcename[id] syntax available in the DSL + class SyntaxSugar + def initialize(name) + @name = name + end + + def [](other) = "#{@name}['#{other}']" + end + + def method_missing(method_name) = SyntaxSugar.new(method_name) + def respond_to_missing? = true + + def depends_on(*others) + @depends_on = {} if @depends_on.nil? + others.each do |other| + info "Registered dependency on #{other}" + @depends_on[other] = {} + end + end + end + + # A resource is something concrete to be managed, e.g. a file, or a CRON job. + class Resource < Keyword + include Dependency + end +end |
