Module: Hijacker

Extended by:
MethodDefiner, Spy
Defined in:
lib/hijacker.rb,
lib/hijacker/spy.rb,
lib/hijacker/config.rb,
lib/hijacker/handler.rb,
lib/hijacker/version.rb,
lib/hijacker/exceptions.rb,
lib/hijacker/method_definer.rb,
lib/hijacker/handlers/logger.rb

Defined Under Namespace

Modules: MethodDefiner, Spy Classes: Handler, Logger, UndefinedUriError

Constant Summary collapse

VERSION =
"0.2.1"

Constants included from Spy

Spy::FORBIDDEN_CLASSES, Spy::REJECTED_METHODS

Class Method Summary collapse

Methods included from Spy

restore, spy, spying

Methods included from MethodDefiner

define_hijacked

Class Method Details

.configure(&block) ⇒ Object



3
4
5
# File 'lib/hijacker/config.rb', line 3

def configure(&block)
  self.instance_eval(&block)
end

.drb_uriObject



11
12
13
14
15
16
17
# File 'lib/hijacker/config.rb', line 11

def drb_uri
  begin
    @@drb_uri
  rescue NameError
    raise UndefinedUriError, "Neither a global nor a local Hijacker server URI is configured. Please refer to the README to find out how to do this."
  end
end

.register(method, args, retval, raised, object, uri = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hijacker.rb', line 19

def register(method, args, retval, raised, object, uri = nil)
  args.map! do |arg|
    {:inspect => arg.inspect, :class => arg.class.name}
  end
  if raised
    raised = {:inspect => raised.message, :class => raised.class.name}
  else
    retval = {:inspect => retval.inspect, :class => retval.class.name}
  end
  object = {:inspect => object.inspect, :class => object.class.name}

  server = DRbObject.new nil, (uri || self.drb_uri)
  server.handle method, args, retval, raised, object
end

.uri(drb) ⇒ Object



7
8
9
# File 'lib/hijacker/config.rb', line 7

def uri(drb)
  @@drb_uri = drb
end