diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/dsl.rb | 2 | ||||
| -rw-r--r-- | lib/dslkeywords/keyword.rb | 2 | ||||
| -rw-r--r-- | lib/dslkeywords/resource.rb | 20 |
3 files changed, 10 insertions, 14 deletions
@@ -25,7 +25,7 @@ module RCM def initialize(reset) DSL.reset! if reset - @id = "dsl[#{@@rcm_counter += 1}]" + @id = "dsl(#{@@rcm_counter += 1})" @conds_met = true @scheduled = [] yield self if block_given? diff --git a/lib/dslkeywords/keyword.rb b/lib/dslkeywords/keyword.rb index 2696e41..2dfff91 100644 --- a/lib/dslkeywords/keyword.rb +++ b/lib/dslkeywords/keyword.rb @@ -9,7 +9,7 @@ module RCM include Options include Log - def initialize(name) = @id = "#{self.class.to_s.sub('RCM::', '').downcase}['#{name}']" + def initialize(name) = @id = "#{self.class.to_s.sub('RCM::', '').downcase}('#{name}')" def to_s = @id end end diff --git a/lib/dslkeywords/resource.rb b/lib/dslkeywords/resource.rb index c9098d4..18239fc 100644 --- a/lib/dslkeywords/resource.rb +++ b/lib/dslkeywords/resource.rb @@ -13,31 +13,27 @@ module RCM end end - # Only to have the resourcename[id] syntax available in the DSL - class SyntaxSugar - def initialize(name) = @name = name - def [](other) = "#{@name}['#{other}']" - end - class NoSuchResourceType < StandardError; end - def method_missing(method_name) + def method_missing(method_name, *args) raise NoSuchResourceType, "No such resource type: #{method_name}" unless @valid_resources.include?(method_name) - SyntaxSugar.new(method_name) + args.map { |arg| "#{method_name}('#{arg}')" } end def respond_to_missing? = true def depends_on(*others) - @dependencies = {} if @dependencies.nil? - others.each do |other| + @depends_on = {} if @depends_on.nil? + return @depends_on if others.empty? + + others.flatten.each do |other| info "Registered dependency on #{other}" - @dependencies[other] = {} + @depends_on[other] = {} end end - def dependencies = @dependencies.nil ? [] : @dependencies + def depends_on?(other) = @depends_on.nil? ? false : @depends_on.key?(other) end # A resource is something concrete to be managed, e.g. a file, or a CRON job. |
