Method: Context::BaseContext.wrap

Defined in:
lib/context/base_context.rb

.wrap(parent_context, **args) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/context/base_context.rb', line 55

def wrap(parent_context, **args)
  existing_public_methods = parent_context.context_method_mapping.keys
  new_public_methods = public_instance_methods(false)
  redefined_methods = existing_public_methods & new_public_methods
  redefined_methods.reject! { |method| is_decorated?(method) }

  unless redefined_methods.empty?
    raise Context::MethodOverrideError.new(self, redefined_methods)
  end

  new(parent_context: parent_context, **args)
end