Module: Rumai::ExportInstanceMethods
- Included in:
- Node
- Defined in:
- lib/rumai/fs.rb
Overview
Makes instance methods accessible through class methods. This is done to emulate the File class:
File.exist? "foo"
File.new("foo").exist?
Both of the above expressions are equivalent.
Class Method Summary collapse
Class Method Details
.extended(target) ⇒ Object
207 208 209 210 211 212 213 214 215 |
# File 'lib/rumai/fs.rb', line 207 def self.extended target # @private target.instance_methods(false).each do |meth| (class << target; self; end).instance_eval do define_method meth do |path, *args| new(path).__send__(meth, *args) end end end end |