Method: Chef::Mixin::FromFile#from_file

Defined in:
lib/chef/mixin/from_file.rb

#from_file(filename) ⇒ Object

Loads a given ruby file, and runs instance_eval against it in the context of the current object.

Raises an IOError if the file cannot be found, or is not readable.



31
32
33
34
35
36
37
38
# File 'lib/chef/mixin/from_file.rb', line 31

def from_file(filename)
  self.source_file = filename
  if File.file?(filename) && File.readable?(filename)
    instance_eval(IO.read(filename), filename, 1)
  else
    raise IOError, "Cannot open or read #{filename}!"
  end
end