Method: Chef::Mixin::FromFile#class_from_file

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

#class_from_file(filename) ⇒ Object

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

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



40
41
42
43
44
45
46
# File 'lib/chef/mixin/from_file.rb', line 40

def class_from_file(filename)
  if File.exists?(filename) && File.readable?(filename)
    self.class_eval(IO.read(filename), filename, 1)
  else
    raise IOError, "Cannot open or read #{filename}!"
  end
end