Class: Orchestra::Recording::Playback::Factory
- Inherits:
-
Object
- Object
- Orchestra::Recording::Playback::Factory
- Defined in:
- lib/orchestra/recording/playback.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #<<(record) ⇒ Object
- #build(service_recording) ⇒ Object
-
#initialize ⇒ Factory
constructor
A new instance of Factory.
- #singleton ⇒ Object
Constructor Details
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
20 21 22 |
# File 'lib/orchestra/recording/playback.rb', line 20 def klass @klass end |
Instance Method Details
#<<(record) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/orchestra/recording/playback.rb', line 33 def << record method = record[:method].to_sym unless klass.instance_methods.include? method klass.send :define_method, method do |*args| mocks[method][args] end end mocks[method][record[:input]] = record[:output] end |
#build(service_recording) ⇒ Object
27 28 29 30 31 |
# File 'lib/orchestra/recording/playback.rb', line 27 def build service_recording record = method :<< service_recording.each &record klass.new mocks end |
#singleton ⇒ Object
41 42 43 |
# File 'lib/orchestra/recording/playback.rb', line 41 def singleton singleton = class << instance ; self end end |