Class: Surrogate::Endower
- Inherits:
-
Object
- Object
- Surrogate::Endower
- Defined in:
- lib/surrogate/endower.rb
Overview
Adds surrogate behaviour to your class / singleton class / instances
please refactor me! …may not be possible :( Can we move all method definitions into this class?
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#klass ⇒ Object
Returns the value of attribute klass.
Class Method Summary collapse
Instance Method Summary collapse
- #endow ⇒ Object
-
#initialize(klass, &block) ⇒ Endower
constructor
A new instance of Endower.
Constructor Details
#initialize(klass, &block) ⇒ Endower
Returns a new instance of Endower.
22 23 24 |
# File 'lib/surrogate/endower.rb', line 22 def initialize(klass, &block) self.klass, self.block = klass, block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
20 21 22 |
# File 'lib/surrogate/endower.rb', line 20 def block @block end |
#klass ⇒ Object
Returns the value of attribute klass.
20 21 22 |
# File 'lib/surrogate/endower.rb', line 20 def klass @klass end |
Class Method Details
.add_hook(&block) ⇒ Object
8 9 10 |
# File 'lib/surrogate/endower.rb', line 8 def self.add_hook(&block) hooks << block end |
.endow(klass, &block) ⇒ Object
16 17 18 |
# File 'lib/surrogate/endower.rb', line 16 def self.endow(klass, &block) new(klass, &block).endow end |
.hooks ⇒ Object
12 13 14 |
# File 'lib/surrogate/endower.rb', line 12 def self.hooks @hooks ||= [] end |
Instance Method Details
#endow ⇒ Object
26 27 28 29 |
# File 'lib/surrogate/endower.rb', line 26 def endow endow_klass endow_singleton_class end |