Alexander Miles Alexander Miles - 1 year ago 74
Ruby Question

How to explicitly reference core classes in Ruby?

I'm working with Chef, and I have run into a situation where I need to use the Ruby

File.dirname()
class method. Problem is, Chef overloads the core class with
Chef::Resource::File
when executing code within a
ruby_block
resource. How can one explicitly reference the core namespace File class?

Answer Source

Prepend the class name with ::, i.e., ::File.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download