Module: TorqueBox::Codecs

Defined in:
core/lib/torquebox/codecs.rb,
core/lib/torquebox/codecs/edn.rb,
core/lib/torquebox/codecs/marshal.rb,
core/lib/torquebox/codecs/json.rb,
core/lib/torquebox/codecs/marshal_smart.rb,
core/lib/torquebox/codecs/marshal_base64.rb

Defined Under Namespace

Modules: EDN, JSON, Marshal, MarshalBase64, MarshalSmart

Class Method Summary (collapse)

Class Method Details

+ (Object) [](key)



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'core/lib/torquebox/codecs.rb', line 32

def [](key)
  case key
  when :edn
    # This is only so any issues requiring the edn codec bubble
    # up when it gets used
    require 'torquebox/codecs/edn' unless defined?(TorqueBox::Codecs::EDN)
    TorqueBox::Codecs::EDN
  when :json
    # This is only so any issues requiring the json codec bubble
    # up when it gets used
    require 'torquebox/codecs/json' unless defined?(TorqueBox::Codecs::JSON)
    TorqueBox::Codecs::JSON
  when :marshal
    TorqueBox::Codecs::Marshal
  when :marshal_base64
    MarshalBase64
  when :marshal_smart
    MarshalSmart
  else
    raise "Unsupported codec #{key}"
  end
end

+ (Object) decode(data, encoding)



59
60
61
# File 'core/lib/torquebox/codecs.rb', line 59

def decode(data, encoding)
  self[encoding].decode(data)
end

+ (Object) encode(data, encoding)



55
56
57
# File 'core/lib/torquebox/codecs.rb', line 55

def encode(data, encoding)
  self[encoding].encode(data)
end