Class: Surrogate::Hatchling
- Inherits:
-
Object
- Object
- Surrogate::Hatchling
- Defined in:
- lib/surrogate/hatchling.rb
Instance Attribute Summary collapse
-
#hatchery ⇒ Object
Returns the value of attribute hatchery.
-
#instance ⇒ Object
Returns the value of attribute instance.
Instance Method Summary collapse
- #api_methods ⇒ Object
-
#initialize(instance, hatchery) ⇒ Hatchling
constructor
A new instance of Hatchling.
- #invocations(method_name) ⇒ Object
- #invoke_method(method_name, args, &block) ⇒ Object
- #prepare_method(method_name, args, &block) ⇒ Object
- #prepare_method_queue(method_name, args, &block) ⇒ Object
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
#hatchery ⇒ Object
Returns the value of attribute hatchery.
4 5 6 |
# File 'lib/surrogate/hatchling.rb', line 4 def hatchery @hatchery end |
#instance ⇒ Object
Returns the value of attribute instance.
4 5 6 |
# File 'lib/surrogate/hatchling.rb', line 4 def instance @instance end |
Instance Method Details
#api_methods ⇒ Object
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 |