Sha256: c20c32959e8ea00f2844ec725d041de53671940f603b1f08dc05161dc4b495bc

Contents?: true

Size: 531 Bytes

Versions: 4

Compression:

Stored size: 531 Bytes

Contents

module Moneta
  class Transformer
    module Helper::BSON
      extend self

      if ::BSON::VERSION >= '4.0.0'
        def load value
          ::BSON::Document.from_bson(::BSON::ByteBuffer.new(value))['v']
        end

        def dump value
          ::BSON::Document['v'=>value].to_bson.to_s
        end
      else
        def load value
          ::BSON::Document.from_bson(::StringIO.new(value))['v']
        end

        def dump value
          ::BSON::Document['v'=>value].to_bson
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
moneta-1.1.1 lib/moneta/transformer/helper/bson.rb
moneta-1.1.0 lib/moneta/transformer/helper/bson.rb
moneta-1.0.0 lib/moneta/transformer/helper/bson.rb
moneta-0.8.1 lib/moneta/transformer/helper/bson.rb