Class: MethodObserver
- Inherits:
-
Object
- Object
- MethodObserver
- Defined in:
- lib/method_observer.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ObserverCannotObserveTwiceError
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
3 4 5 |
# File 'lib/method_observer.rb', line 3 def result @result end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
2 3 4 |
# File 'lib/method_observer.rb', line 2 def target @target end |
Class Method Details
.instances ⇒ Object
18 19 20 |
# File 'lib/method_observer.rb', line 18 def self.instances @instances ||= {} end |
.new(*args) ⇒ Object
22 23 24 25 26 |
# File 'lib/method_observer.rb', line 22 def self.new(*args) o = super instances[o.object_id] = o o end |
Instance Method Details
#observe(target) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/method_observer.rb', line 11 def observe(target) raise ObserverCannotObserveTwiceError if @target @target = target make_observable(target) end |