Class: Surrogate::Endower

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, &block) ⇒ Endower

Returns a new instance of Endower.



14
15
16
# File 'lib/surrogate/endower.rb', line 14

def initialize(klass, &block)
  self.klass, self.block = klass, block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



12
13
14
# File 'lib/surrogate/endower.rb', line 12

def block
  @block
end

#klassObject

Returns the value of attribute klass.



12
13
14
# File 'lib/surrogate/endower.rb', line 12

def klass
  @klass
end

Class Method Details

.endow(klass, &block) ⇒ Object



8
9
10
# File 'lib/surrogate/endower.rb', line 8

def self.endow(klass, &block)
  new(klass, &block).endow
end

Instance Method Details

#endowObject



18
19
20
21
# File 'lib/surrogate/endower.rb', line 18

def endow
  endow_klass
  endow_singleton_class
end