Class: Alf::Support::Scope

Inherits:
BasicObject
Defined in:
lib/alf/support/scope.rb

Overview

Implements a sandboxed scope abstraction through a BasicObject.

Example:

module Foo; ... end
module Bar; ... end

Scope.new([Foo, Bar]).evaluate{
  # Foo and Bar instance methods are available
  # Kernel's methods are not
}

Direct Known Subclasses

TupleScope

Defined Under Namespace

Modules: OwnMethods

Instance Method Summary collapse

Constructor Details

#initialize(extensions = [], parent = nil) ⇒ Scope

Creates a scope instance


75
76
77
78
79
80
81
# File 'lib/alf/support/scope.rb', line 75

def initialize(extensions = [], parent = nil)
  @extensions = [ OwnMethods ] + extensions
  @extensions.each do |ext|
    ext.send(:extend_object, self)
  end
  @parent = parent
end