class HareDo::Plugins::Instance

Public Class Methods

new(path) click to toggle source
# File src/lib/haredo/peer.rb, line 65
def initialize(path)
  
  # 1. Create an empty, anonymous module
  @module = Module.new()
  
  # 2. Get it's binding
  @binding = @module.instance_eval 'binding'
  
  # 3. Eval the desired file with the module's binding as
  # context. Everything global in the module will be restricted to the
  # module's namespace.
  Kernel::eval(File.open(path).read(), @binding, path)
end

Public Instance Methods

get(object) click to toggle source

Return a top-level object within the module

# File src/lib/haredo/peer.rb, line 80
def get(object)
  return @module.instance_eval object
end