Class: Ccp::Fixtures::Observer
- Inherits:
-
Object
- Object
- Ccp::Fixtures::Observer
- Defined in:
- lib/ccp/fixtures/observer.rb
Instance Attribute Summary collapse
-
#read ⇒ Object
readonly
Returns the value of attribute read.
-
#write ⇒ Object
readonly
Returns the value of attribute write.
Instance Method Summary collapse
-
#initialize(data) ⇒ Observer
constructor
A new instance of Observer.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(data) ⇒ Observer
Returns a new instance of Observer.
6 7 8 9 10 |
# File 'lib/ccp/fixtures/observer.rb', line 6 def initialize(data) @data = data.must(Typed::Hash) @read = {} @write = {} end |
Instance Attribute Details
#read ⇒ Object (readonly)
Returns the value of attribute read.
4 5 6 |
# File 'lib/ccp/fixtures/observer.rb', line 4 def read @read end |
#write ⇒ Object (readonly)
Returns the value of attribute write.
4 5 6 |
# File 'lib/ccp/fixtures/observer.rb', line 4 def write @write end |
Instance Method Details
#start ⇒ Object
12 13 14 15 |
# File 'lib/ccp/fixtures/observer.rb', line 12 def start @data.events.on(:read ) {|k,v| @read[k] ||= v} @data.events.on(:write) {|k,v| @write[k] = v} end |
#stop ⇒ Object
17 18 19 20 |
# File 'lib/ccp/fixtures/observer.rb', line 17 def stop # remove events (this depends on typed.gem) # NotImplementedYet end |