Class: InlineTesting::TestEnvironment::Context

Inherits:
Object
  • Object
show all
Includes:
MetaTools
Defined in:
lib/inline_testing/test_environment/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(locals_obj) ⇒ Context

Returns a new instance of Context.



7
8
9
# File 'lib/inline_testing/test_environment/context.rb', line 7

def initialize(locals_obj)
  @locals_obj, @delegated_methods = locals_obj, []
end

Instance Method Details

#update_methodsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/inline_testing/test_environment/context.rb', line 11

def update_methods
  
  # TODO..
  # Remove unused delegated methods
  # (@locals_obj.locals.keys - @delegated_methods).each do |local|
  #   @delegated_methods.delete(local)
  #   metaclass.remove_method(local)
  # end
  
  # Delegate locals methods
  @locals_obj.locals.keys.each do |local|
    meta_def(local) { @locals_obj.send(local) } unless metaclass.method_defined?(local)
    @delegated_methods << local
  end
end