Class: Orchestra::Recording
- Inherits:
-
Object
- Object
- Orchestra::Recording
- Defined in:
- lib/orchestra/recording.rb,
lib/orchestra/recording/node.rb,
lib/orchestra/recording/playback.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#output ⇒ Object
Returns the value of attribute output.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Class Method Summary collapse
Instance Method Summary collapse
- #[](attr) ⇒ Object
-
#initialize(services) ⇒ Recording
constructor
A new instance of Recording.
- #replay(operation, override_input = {}) ⇒ Object
- #to_h ⇒ Object
- #to_json(generator) ⇒ Object
- #update(event_name, *args) ⇒ Object
Constructor Details
#initialize(services) ⇒ Recording
Returns a new instance of Recording.
11 12 13 |
# File 'lib/orchestra/recording.rb', line 11 def initialize services @services = services end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
8 9 10 |
# File 'lib/orchestra/recording.rb', line 8 def input @input end |
#output ⇒ Object
Returns the value of attribute output.
8 9 10 |
# File 'lib/orchestra/recording.rb', line 8 def output @output end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
9 10 11 |
# File 'lib/orchestra/recording.rb', line 9 def services @services end |
Class Method Details
.fresh ⇒ Object
3 4 5 6 |
# File 'lib/orchestra/recording.rb', line 3 def self.fresh services = Hash.new do |hsh, service_name| hsh[service_name] = [] end new services end |
Instance Method Details
#[](attr) ⇒ Object
28 29 30 |
# File 'lib/orchestra/recording.rb', line 28 def [] attr to_h[attr] end |
#replay(operation, override_input = {}) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/orchestra/recording.rb', line 44 def replay operation, override_input = {} replayed_services = {} services.each do |svc, service_recording| replayed_services[svc] = Playback.build service_recording end conductor = Conductor.new replayed_services conductor.execute operation, input.merge(override_input) end |
#to_h ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/orchestra/recording.rb', line 32 def to_h { :input => input, :output => output, :service_recordings => services, } end |
#to_json(generator) ⇒ Object
40 41 42 |
# File 'lib/orchestra/recording.rb', line 40 def to_json generator generator.generate to_h end |
#update(event_name, *args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/orchestra/recording.rb', line 15 def update event_name, *args case event_name when :service_accessed then service_name, recording = args @services[service_name] << recording when :operation_entered then _, @input = args when :operation_exited then _, @output = args else end end |