Sha256: 697cce0215345d853a9725dd5636a7355fd7fbb6b2d8b304f22dd77c3e9c1b63
Contents?: true
Size: 1.15 KB
Versions: 28
Compression:
Stored size: 1.15 KB
Contents
=begin rdoc Gives access to conditional statements == Usage has_case "os" do when_is :ubuntu, "git-core" else_is "git" end translates to: case "os" when :ubuntu "git-core" else "git" end =end module PoolParty module Resources class Conditional < Resource default_options( :name => nil ) def self.has_method_name "case" end # When is def when_is(val, output) conditions << [val, output] end def else_is(output) conditions.push([:else, output]) end def conditions @conditions ||= [] end def print_to_chef arr = [] arr << "case #{print_variable(name)}" conditions.each do |cond| if cond[0] == :else arr << "else" arr << " #{print_variable(cond[1])}" break else arr << "when #{print_variable(cond[0])}" arr << " #{print_variable(cond[1])}" end end arr << "end" arr.join("\n") end end end end
Version data entries
28 entries across 28 versions & 3 rubygems