Method: Chef::Resource#to_text

Defined in:
lib/chef/resource.rb

#to_textObject



319
320
321
322
323
324
325
326
327
328
329
# File 'lib/chef/resource.rb', line 319

def to_text
  ivars = instance_variables.map { |ivar| ivar.to_sym } - HIDDEN_IVARS
  text = "# Declared in #{@source_line}\n"
  text << convert_to_snake_case(self.class.name, 'Chef::Resource') + "(\"#{name}\") do\n"
  ivars.each do |ivar|
    if (value = instance_variable_get(ivar)) && !(value.respond_to?(:empty?) && value.empty?)
      text << "  #{ivar.to_s.sub(/^@/,'')}(#{value.inspect})\n"
    end
  end
  text << "end\n"
end