Module: MarkMapper::Plugins::Dumpable

Included in:
Document
Defined in:
lib/mark_mapper/plugins/dumpable.rb

Constant Summary collapse

DUMP_BLACKLIST =
Set.new([:@errors])

Instance Method Summary collapse

Instance Method Details

#marshal_dumpObject


8
9
10
11
12
13
# File 'lib/mark_mapper/plugins/dumpable.rb', line 8

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

#marshal_load(data) ⇒ Object


15
16
17
18
19
# File 'lib/mark_mapper/plugins/dumpable.rb', line 15

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