module Chef::Mixin::FromFile
Attributes
Source path from which the object was loaded
Public Instance Methods
Source
# File lib/chef/mixin/from_file.rb, line 44 def class_from_file(filename) self.source_file = filename if File.file?(filename) && File.readable?(filename) class_eval(IO.read(filename), filename, 1) else raise IOError, "Cannot open or read #{filename}!" end end
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.
Source
# 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
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.