# class FileServing::Content

A class that handles retrieving file contents. It only reads the file when its content is specifically asked for.

### Attributes

content[W]

### Public Class Methods

from_raw(content) click to toggle source

    # File lib/puppet/file_serving/content.rb, line 18
    def self.from_raw(content)
      instance = new("/this/is/a/fake/path")
      instance.content = content
      instance
    end

supported_formats() click to toggle source

    # File lib/puppet/file_serving/content.rb, line 14
    def self.supported_formats
      [:raw]
    end

### Public Instance Methods

collect() click to toggle source

BF: we used to fetch the file content here, but this is counter-productive for puppetmaster streaming of file content. So collect just returns itself

    # File lib/puppet/file_serving/content.rb, line 26
    def collect
      return if stat.ftype == "directory"
      self
    end

content() click to toggle source

Read the content of our file in.

    # File lib/puppet/file_serving/content.rb, line 32
    def content
      unless @content
        # This stat can raise an exception, too.
        raise(ArgumentError, "Cannot read the contents of links unless following links") if stat.ftype == "symlink"

        @content = IO.binread(full_path)
      end
      @content
    end

to_raw() click to toggle source

    # File lib/puppet/file_serving/content.rb, line 42
    def to_raw
      File.new(full_path, "rb")
    end