Method: Puppet::Util::FileParsing::FileRecord#join

Defined in:
lib/puppet/util/fileparsing.rb

#join(details) ⇒ Object

Convert a record into a line by joining the fields together appropriately. This is pulled into a separate method so it can be called by the hooks.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/puppet/util/fileparsing.rb', line 80

def join(details)
  joinchar = self.joiner

  fields.collect { |field|
    # If the field is marked absent, use the appropriate replacement
    if details[field] == :absent or details[field] == [:absent] or details[field].nil?
      if self.optional.include?(field)
        self.absent
      else
        raise ArgumentError, "Field '#{field}' is required"
      end
    else
      details[field].to_s
    end
  }.reject { |c| c.nil?}.join(joinchar)
end