lib/nfagent/payload.rb in nfagent-0.9.19 vs lib/nfagent/payload.rb in nfagent-0.9.20

- old
+ new

@@ -1,8 +1,8 @@ module NFAgent - class Payload < Struct.new(:data, :checksum, :filename, :line_count, :chunk_expired) + class Payload < Struct.new(:data, :checksum, :filename, :line_count, :chunk_expired, :key) def initialize yield self end def attempt @@ -21,15 +21,17 @@ def size (self.data || "").size + 1 end def to_hash - { + ret = { "payload" => self.data, "checksum" => self.checksum, "line_count" => self.line_count, "chunk_expired" => self.chunk_expired } + ret["key"] = self.key unless self.key.blank? + ret end def write_to_disk(directory) File.open(File.join(directory, "#{self.checksum}-#{self.attempt}"), "w") do |file| file << self.data