class WebSocketVCR::RecordEntry

Attributes

data[RW]
event[RW]
operation[RW]
type[RW]

Public Class Methods

parse(obj, erb_variables = nil) click to toggle source
# 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