Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

TypeError (can't copy BigDecimal) #6

Open
spalenza opened this issue Jan 22, 2014 · 8 comments
Open

TypeError (can't copy BigDecimal) #6

spalenza opened this issue Jan 22, 2014 · 8 comments

Comments

@spalenza
Copy link

Hi! I need to make a depth copy of objects with BigDecimal values.
When a try, I get this error. TypeError (can't copy BigDecimal)

Thanks.

@balmma
Copy link
Collaborator

balmma commented Jan 22, 2014

Ok, in fact there are some classes in Ruby which are no cloneable. We catched most of them but probably missed the BigDecimal class. Should be a fairly easy one to fix.

Rodolfo Spalenza [email protected] schrieb:

Hi! I need to make a depth copy of objects with BigDecimal values.
When a try, I get this error. TypeError (can't copy BigDecimal)

Thanks.


Reply to this email directly or view it on GitHub.

@balmma
Copy link
Collaborator

balmma commented Jan 22, 2014

Uhh, not that simple since BigDecimal is part of the stdlib and not core. Will have a look on it 2moro.

@spalenza
Copy link
Author

Hi @balmma, why you can't include stdlib?
Thanks.

@balmma
Copy link
Collaborator

balmma commented Jan 23, 2014

Well, it's not that simple in a C extension. Most probably the best way would be to catch the exception and use the original value. But I need to do some work to get this running.

@balmma
Copy link
Collaborator

balmma commented Jan 23, 2014

Problem fixed. I added a check to not clone Numeric and it's descendants at all (just take the same object). Created GEM version 0.5.0.

@balmma balmma closed this as completed Jan 23, 2014
@spalenza
Copy link
Author

Hi @balmma,
It keep a problem. I try this:

require "bigdecimal"
require "deep_clone"

big_decimal = BigDecimal.new(1)
new_big_decimal = DeepClone.clone big_decimal

And return this:

TypeError: can't copy BigDecimal
    from (irb):5:in `initialize_copy'
    from (irb):5:in `initialize_clone'
    from (irb):5:in `clone'
    from (irb):5

@balmma balmma reopened this Jan 24, 2014
@balmma
Copy link
Collaborator

balmma commented Jan 31, 2014

Does it work in the newest version? Btw. which Ruby version are you using?

@spalenza
Copy link
Author

ruby 2.0.0p353 its working fine but with 1.9.3p374 I get a same error (both with RVM).
I'm using 0.6.0 gem version (the rubygems version).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants