Class: Surrogate::Hatchling

Inherits:
Object
  • Object
show all
Defined in:
lib/surrogate/hatchling.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, hatchery) ⇒ Hatchling

Returns a new instance of Hatchling.



6
7
8
# File 'lib/surrogate/hatchling.rb', line 6

def initialize(instance, hatchery)
  self.instance, self.hatchery = instance, hatchery
end

Instance Attribute Details

#hatcheryObject

Returns the value of attribute hatchery.



4
5
6
# File 'lib/surrogate/hatchling.rb', line 4

def hatchery
  @hatchery
end

#instanceObject

Returns the value of attribute instance.



4
5
6
# File 'lib/surrogate/hatchling.rb', line 4

def instance
  @instance
end

Instance Method Details

#api_methodsObject



10
11
12
# File 'lib/surrogate/hatchling.rb', line 10

def api_methods
  hatchery.api_methods
end

#invocations(method_name) ⇒ Object



36
37
38
# File 'lib/surrogate/hatchling.rb', line 36

def invocations(method_name)
  invoked_methods[method_name]
end

#invoke_method(method_name, args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/surrogate/hatchling.rb', line 14

def invoke_method(method_name, args, &block)
  invoked_methods[method_name] << args
  return get_default method_name, args unless has_ivar? method_name
  ivar = get_ivar method_name
  case ivar
  when MethodQueue
    play_from_queue ivar, method_name
  when Exception
    raise ivar
  else
    ivar
  end
end

#prepare_method(method_name, args, &block) ⇒ Object



28
29
30
# File 'lib/surrogate/hatchling.rb', line 28

def prepare_method(method_name, args, &block)
  set_ivar method_name, *args
end

#prepare_method_queue(method_name, args, &block) ⇒ Object



32
33
34
# File 'lib/surrogate/hatchling.rb', line 32

def prepare_method_queue(method_name, args, &block)
  set_ivar method_name, MethodQueue.new(args)
end