Class: V8::Portal::Interceptors::Interceptor

Inherits:
Object
  • Object
show all
Defined in:
lib/v8/portal/interceptors.rb

Instance Method Summary collapse

Constructor Details

#initialize(portal) ⇒ Interceptor

Returns a new instance of Interceptor.



49
50
51
# File 'lib/v8/portal/interceptors.rb', line 49

def initialize(portal)
  @to, @access = portal, portal.access
end

Instance Method Details

#intercept(info, retval = nil, &code) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/v8/portal/interceptors.rb', line 53

def intercept(info, retval = nil, &code)
  obj = @to.rb(info.This())
  intercepts = true
  result = @to.caller.protect do
    dontintercept = proc do
      intercepts = false
    end
    code.call(obj, dontintercept)
  end
  intercepts ? (retval || result) : C::Empty
end