Skip to content

Commit

Permalink
Make marshal dump work for memory store (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer authored and antstorm committed Apr 26, 2017
1 parent 5ecaa8d commit 3a126f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/money/rates_store/memory.rb
Expand Up @@ -58,10 +58,9 @@ def get_rate(currency_iso_from, currency_iso_to)
end

def marshal_dump
[self.class, index, options]
[self.class, options, index]
end


# Wraps block execution in a thread-safe transaction
def transaction(&block)
if @in_transaction || options[:without_mutex]
Expand Down
11 changes: 11 additions & 0 deletions spec/rates_store/memory_spec.rb
Expand Up @@ -66,4 +66,15 @@
end
end
end

describe '#marshal_dump' do
let(:subject) { Money::RatesStore::Memory.new(:optional => true) }

it 'can reload' do
bank = Money::Bank::VariableExchange.new(subject)
bank = Marshal.load(Marshal.dump(bank))
expect(bank.store.instance_variable_get(:@options)).to eq subject.instance_variable_get(:@options)
expect(bank.store.instance_variable_get(:@index)).to eq subject.instance_variable_get(:@index)
end
end
end

0 comments on commit 3a126f4

Please sign in to comment.