summaryrefslogtreecommitdiff
path: root/lib/dslkeywords/only_when.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-02-15 09:25:57 +0200
committerPaul Buetow <paul@buetow.org>2025-02-15 09:25:57 +0200
commit6879b03b2735b082b913ab17e63857f464f53c93 (patch)
tree525b1b78983ba3b3d6f4e218daf0055edf7728a9 /lib/dslkeywords/only_when.rb
parent463f429166c5ace855998b433e865140f9b737ca (diff)
dsl keyword base class added
Diffstat (limited to 'lib/dslkeywords/only_when.rb')
-rw-r--r--lib/dslkeywords/only_when.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/dslkeywords/only_when.rb b/lib/dslkeywords/only_when.rb
index 485fd42..f23c33e 100644
--- a/lib/dslkeywords/only_when.rb
+++ b/lib/dslkeywords/only_when.rb
@@ -1,9 +1,15 @@
+require 'socket'
+
+require_relative 'keyword'
+
module RCM
# OnlyWhen (e.g. run on host foo)
- class OnlyWhen
- require 'socket'
+ class OnlyWhen < Keyword
+ def initialize(dsl_id)
+ super(dsl_id)
+ @conds = {}
+ end
- def initialize = @conds = {}
def is(arg) = arg
def method_missing(method_name, *args) = @conds[method_name] = args.first
def respond_to_missing? = true
@@ -18,7 +24,7 @@ module RCM
# Add 'only_when' to DSL
class DSL
def only_when(&block)
- conds = OnlyWhen.new
+ conds = OnlyWhen.new(id)
conds.instance_eval(&block)
@conds_met = conds.met?
end