Class: Surrogate::Hatchery
- Inherits:
-
Object
- Object
- Surrogate::Hatchery
- Defined in:
- lib/surrogate/hatchery.rb
Overview
This manages the definitions that were given to the class The hatchlings are added to the instances, and they look here to find out about how their methods are implemented.
Instance Attribute Summary collapse
-
#klass ⇒ Object
currently options don’t do anything, they’re just there because the hatchery is the definition of the surrogate so it makes sense for it to store values used by the endower when constructing clones.
-
#options ⇒ Object
currently options don’t do anything, they’re just there because the hatchery is the definition of the surrogate so it makes sense for it to store values used by the endower when constructing clones.
Instance Method Summary collapse
- #api_method_for(name) ⇒ Object
- #api_method_names ⇒ Object
- #api_methods ⇒ Object
- #define(method_name, options = {}, &block) ⇒ Object
-
#initialize(klass, options) ⇒ Hatchery
constructor
A new instance of Hatchery.
Constructor Details
#initialize(klass, options) ⇒ Hatchery
Returns a new instance of Hatchery.
13 14 15 16 |
# File 'lib/surrogate/hatchery.rb', line 13 def initialize(klass, ) self.klass, self. = klass, klass_can_define_api_methods end |
Instance Attribute Details
#klass ⇒ Object
currently options don’t do anything, they’re just there because the hatchery is the definition of the surrogate so it makes sense for it to store values used by the endower when constructing clones
11 12 13 |
# File 'lib/surrogate/hatchery.rb', line 11 def klass @klass end |
#options ⇒ Object
currently options don’t do anything, they’re just there because the hatchery is the definition of the surrogate so it makes sense for it to store values used by the endower when constructing clones
11 12 13 |
# File 'lib/surrogate/hatchery.rb', line 11 def @options end |
Instance Method Details
#api_method_for(name) ⇒ Object
34 35 36 37 |
# File 'lib/surrogate/hatchery.rb', line 34 def api_method_for(name) = api_methods[name] && .default_proc end |
#api_method_names ⇒ Object
30 31 32 |
# File 'lib/surrogate/hatchery.rb', line 30 def api_method_names api_methods.keys - [:initialize] end |
#api_methods ⇒ Object
26 27 28 |
# File 'lib/surrogate/hatchery.rb', line 26 def api_methods @api_methods ||= {} end |
#define(method_name, options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/surrogate/hatchery.rb', line 18 def define(method_name, ={}, &block) add_api_method_for method_name add_verb_helpers_for method_name add_noun_helpers_for method_name api_methods[method_name] = MethodDefinition.new method_name, , block klass end |