summaryrefslogtreecommitdiff
path: root/lib/autorequire/only_when.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-06 23:52:43 +0200
committerPaul Buetow <paul@buetow.org>2024-12-06 23:52:43 +0200
commit7c23b27007ca62ff545411aa3d1200fce4eec8c9 (patch)
tree86e4215580368b5c6f164bb79c2a0f91f479c7f1 /lib/autorequire/only_when.rb
parent36c00a4509e745e4b29b1194faca4dca830a9b95 (diff)
refactor
Diffstat (limited to 'lib/autorequire/only_when.rb')
-rw-r--r--lib/autorequire/only_when.rb37
1 files changed, 0 insertions, 37 deletions
diff --git a/lib/autorequire/only_when.rb b/lib/autorequire/only_when.rb
deleted file mode 100644
index 2700bee..0000000
--- a/lib/autorequire/only_when.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-module RCM
- # OnlyWhen (e.g. run on host foo)
- class OnlyWhen
- require 'socket'
-
- def initialize
- @conds = {}
- end
-
- def is(arg)
- arg
- end
-
- def method_missing(method_name, *args, &block)
- @conds[method_name] = args.first
- end
-
- def respond_to_missing?
- true
- end
-
- def met?
- return false if @conds.key?(:hostname) && Socket.gethostname != @conds[:hostname].to_s
-
- true
- end
- end
-
- # Add 'only_when' to DSL
- class RCM
- def only_when(&block)
- conds = OnlyWhen.new
- conds.instance_eval(&block)
- @conds_met = conds.met?
- end
- end
-end