Sha256: b3263ab2225f76f3bc04b3c03f3ae2ca785af4f1da2669aabc1875eb4b5730a2

Contents?: true

Size: 485 Bytes

Versions: 15

Compression:

Stored size: 485 Bytes

Contents

require 'set'

module MongoMapper
  module Plugins
    module Dumpable
      DUMP_BLACKLIST = Set.new([:@errors])

      def marshal_dump
        instance_variables.map(&:to_sym).inject({}) do |h, var|
          h[var] = instance_variable_get(var) unless DUMP_BLACKLIST.include?(var) or var.to_s.start_with?("@__")
          h
        end
      end

      def marshal_load(data)
        data.each do |k, v|
          instance_variable_set(k, v)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mongo_mapper-0.17.0 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.16.0 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.15.6 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.15.5 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.15.4 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.15.3 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.15.2 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.15.1 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.15.0 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.14.0 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.14.0.rc1 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.13.1 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.13.0 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.13.0.beta2 lib/mongo_mapper/plugins/dumpable.rb
mongo_mapper-0.13.0.beta1 lib/mongo_mapper/plugins/dumpable.rb