Class: WebSocketVCR::RecordEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_websocket_vcr/cassette.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



124
125
126
# File 'lib/simple_websocket_vcr/cassette.rb', line 124

def data
  @data
end

#eventObject

Returns the value of attribute event.



124
125
126
# File 'lib/simple_websocket_vcr/cassette.rb', line 124

def event
  @event
end

#operationObject

Returns the value of attribute operation.



124
125
126
# File 'lib/simple_websocket_vcr/cassette.rb', line 124

def operation
  @operation
end

#typeObject

Returns the value of attribute type.



124
125
126
# File 'lib/simple_websocket_vcr/cassette.rb', line 124

def type
  @type
end

Class Method Details

.parse(obj, erb_variables = nil) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/simple_websocket_vcr/cassette.rb', line 126

def self.parse(obj, erb_variables = nil)
  record_entry = RecordEntry.new
  record_entry.operation = obj['operation']
  record_entry.event = obj['event'] if obj['event']
  record_entry.type = obj['type'] if obj['type']
  record_entry.data = obj['data'] if obj['data']

  # do the ERB substitution
  if erb_variables && record_entry.type != 'binary'
    require 'ostruct'
    namespace = OpenStruct.new(erb_variables)
    record_entry.data = ERB.new(record_entry.data).result(namespace.instance_eval { binding })
  end

  record_entry
end