Add conversion to Money from Hash when hash key names are the same as Money's instance variable names
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.
Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 24e9fc164b6485f45942a8f37212558c72d0d0f7 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 94276f14541f2e9398abda0746ed680cefcd15f1 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 5bb6f3add343c27a7c49c9095358b5a7fb64faa2 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 5bb6f3add343c27a7c49c9095358b5a7fb64faa2 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
Coverage increased (+0.002%) to 98.965% when pulling 5bb6f3add343c27a7c49c9095358b5a7fb64faa2 on Karolis-Sakavicius:improve-hash-conversion into 7dda95107a065918b90b4873c93fbc406308c2a0 on RubyMoney:master.
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.