Class: WebSocketVCR::RecordedSession
- Inherits:
-
Object
- Object
- WebSocketVCR::RecordedSession
show all
- Defined in:
- lib/simple_websocket_vcr/cassette.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(entries, erb_variables = nil) ⇒ RecordedSession
Returns a new instance of RecordedSession.
83
84
85
86
|
# File 'lib/simple_websocket_vcr/cassette.rb', line 83
def initialize(entries, erb_variables = nil)
@record_entries = entries
@erb_variables = erb_variables
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
106
107
108
|
# File 'lib/simple_websocket_vcr/cassette.rb', line 106
def method_missing(method_name, *args, &block)
@record_entries.__send__(method_name, *args, &block)
end
|
Instance Attribute Details
#record_entries ⇒ Object
Returns the value of attribute record_entries.
81
82
83
|
# File 'lib/simple_websocket_vcr/cassette.rb', line 81
def record_entries
@record_entries
end
|
Instance Method Details
#head ⇒ Object
102
103
104
|
# File 'lib/simple_websocket_vcr/cassette.rb', line 102
def head
@record_entries.empty? ? nil : RecordEntry.parse(@record_entries.first, @erb_variables)
end
|
#next ⇒ Object
98
99
100
|
# File 'lib/simple_websocket_vcr/cassette.rb', line 98
def next
RecordEntry.parse(@record_entries.shift, @erb_variables)
end
|
#store(entry) ⇒ Object
88
89
90
91
92
93
94
95
96
|
# File 'lib/simple_websocket_vcr/cassette.rb', line 88
def store(entry)
hash = entry.is_a?(RecordEntry) ? entry.attributes.map(&:to_s) : Hash[entry.map { |k, v| [k.to_s, v.to_s] }]
if !hash['data'].nil? && !@erb_variables.nil? && hash['type'] != 'binary'
@erb_variables.each do |k, v|
hash['data'].gsub! v.to_s, "<%= #{k} %>"
end
end
@record_entries << hash
end
|