Module: Ohai::Mixin::FromFile

Included in:
System
Defined in:
lib/ohai/mixin/from_file.rb

Instance Method Summary collapse

Instance Method Details

#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.



27
28
29
30
31
32
33
# File 'lib/ohai/mixin/from_file.rb', line 27

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