Sha256: 09be7cdbfdef83dfa035c05ba944ec33b8034593fa64eed3b2e9a7e147b74d6d
Contents?: true
Size: 814 Bytes
Versions: 3
Compression:
Stored size: 814 Bytes
Contents
require 'multi_json' module Macaroons class JsonSerializer def serialize(macaroon) serialized = { location: macaroon.location, identifier: macaroon.identifier, caveats: macaroon.caveats.map!(&:to_h), signature: macaroon.signature } MultiJson.dump(serialized) end def deserialize(serialized) deserialized = MultiJson.load(serialized) macaroon = Macaroons::RawMacaroon.new(key: 'no_key', identifier: deserialized['identifier'], location: deserialized['location']) deserialized['caveats'].each do |c| caveat = Macaroons::Caveat.new(c['cid'], c['vid'], c['cl']) macaroon.caveats << caveat end macaroon.signature = Utils.unhexlify(deserialized['signature']) macaroon end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
macaroons-0.5.3 | lib/macaroons/serializers/json.rb |
macaroons-0.5.2 | lib/macaroons/serializers/json.rb |
macaroons-0.5.1 | lib/macaroons/serializers/json.rb |