RubyMoney / monetize

A library for converting various objects into `Money` objects.
MIT License
430 stars 107 forks source link

Improve conversion to Money from Hash #92

Closed Karolis-Sakavicius closed 7 years ago

Karolis-Sakavicius commented 7 years ago

Related to money-rails. as_json method creates a hash with keys "fractional", "currency" & "bank" - identical names to Money instance variable names, also passes currency as a hash, consisting of Money::Currency instance variables. Because conversion from Hash expected "cents" key and "currency" as an ISO string, 100.to_money.as_json.to_money failed.

I think this conversion functionality should be implemented here and not in money-rails because it's fairly common practice to use object's instance variable names when converting to Hash as I know.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 94276f14541f2e9398abda0746ed680cefcd15f1 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 5bb6f3add343c27a7c49c9095358b5a7fb64faa2 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 5bb6f3add343c27a7c49c9095358b5a7fb64faa2 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.002%) to 98.965% when pulling 5bb6f3add343c27a7c49c9095358b5a7fb64faa2 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.

antstorm commented 7 years ago

Looks good now, thanks @Karolis-Sakavicius !