Fix crash building a Mash w/ IndifferentAccess from HashWithIndifferentAccess #277

Merged
merged 1 commit into from Feb 5, 2015

Conversation

Projects
None yet
3 participants
@gardenofwine
Contributor

gardenofwine commented Feb 4, 2015

When using an ActiveRecord::HashWithIndifferentAccess that is nested (i.e. {a: {b: 1}}) to create a Mash with the IndifferentAccess extension, an ArgumentException is raised. This is because the IndifferentAccess method convert_value overrides ActiveRecord::HashWithIndifferentAccess's method of the same name. Changing the method name in IndifferentAccess solves the issue.

CHANGELOG.md
@@ -1,6 +1,7 @@
## Next Release
* [#269](https://github.com/intridea/hashie/pull/272): Added Hashie::Extensions::DeepLocate - [@msievers](https://github.com/msievers).
+* [#270](https://github.com/intridea/hashie/pull/277): Fixed crash with IndifferentAccess and HashWithIndifferentAccess - [@gardenofwine](https://github.com/gardenofwine).

This comment has been minimized.

@dblock

dblock Feb 4, 2015

Contributor

This should be something other than "crash", maybe "Fix: ArgumentException raised when ..."

@dblock

dblock Feb 4, 2015

Contributor

This should be something other than "crash", maybe "Fix: ArgumentException raised when ..."

@@ -35,6 +36,10 @@ class CoercableHash < Hash
include Hashie::Extensions::MergeInitializer
end
+ class MashWithIndifferentAccess < Hashie::Mash

This comment has been minimized.

@dblock

dblock Feb 4, 2015

Contributor

I think this should split into a separate file, how about indifferent_access_with_rais_hwia_spec and mash_with_indifferent_access_spec?

@dblock

dblock Feb 4, 2015

Contributor

I think this should split into a separate file, how about indifferent_access_with_rais_hwia_spec and mash_with_indifferent_access_spec?

This comment has been minimized.

@yonbergman

yonbergman Feb 5, 2015

I"m not entirely convinced, since this issue only arises when you mix both ways of indifference.
Without Rails' hwia this wouldn't fail.

@yonbergman

yonbergman Feb 5, 2015

I"m not entirely convinced, since this issue only arises when you mix both ways of indifference.
Without Rails' hwia this wouldn't fail.

This comment has been minimized.

@gardenofwine

gardenofwine Feb 5, 2015

Contributor

@dblock The text at the top of indifferent_access_with_rais_hwia_spec says:

# This set of tests verifies that Hashie::Extensions::IndifferentAccess works with
# ActiveSupport HashWithIndifferentAccess hashes. See #164 and #166 for details.

Therefor I think the place of the test is in this file and not in a separate one; However, if you insist I'll move it to a separate file - and change the comment at the top of indifferent_access_with_rais_hwia_spec

@gardenofwine

gardenofwine Feb 5, 2015

Contributor

@dblock The text at the top of indifferent_access_with_rais_hwia_spec says:

# This set of tests verifies that Hashie::Extensions::IndifferentAccess works with
# ActiveSupport HashWithIndifferentAccess hashes. See #164 and #166 for details.

Therefor I think the place of the test is in this file and not in a separate one; However, if you insist I'll move it to a separate file - and change the comment at the top of indifferent_access_with_rais_hwia_spec

This comment has been minimized.

@dblock

dblock Feb 5, 2015

Contributor

Fair enough, lets keep this.

@dblock

dblock Feb 5, 2015

Contributor

Fair enough, lets keep this.

@dblock

This comment has been minimized.

Show comment
Hide comment
@dblock

dblock Feb 4, 2015

Contributor

See my comments above, minor picky things.

(Rbx build failure is unrelated, caused by rspec/rspec-core#1863)

Contributor

dblock commented Feb 4, 2015

See my comments above, minor picky things.

(Rbx build failure is unrelated, caused by rspec/rspec-core#1863)

Fix crash building a Mash w/ IndifferentAccess from HashWithIndiffere…
…ntAccess

When using an ActiveRecord::HashWithIndifferentAccess that is nested (i.e. {a: {b: 1}}) to create a Mash with the IndifferentAccess extension, an ArgumentException is raised. This is because the IndifferentAccess method `convert_value` overrides ActiveRecord::HashWithIndifferentAccess's method of the same name. Changing the method name in IndifferentAccess solves the issue.

dblock added a commit that referenced this pull request Feb 5, 2015

Merge pull request #277 from gardenofwine/fix_integration_with_hash_w…
…ith_indifferent_access

Fix crash building a Mash w/ IndifferentAccess from HashWithIndifferentAccess

@dblock dblock merged commit 09821f3 into intridea:master Feb 5, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@dblock

This comment has been minimized.

Show comment
Hide comment
@dblock

dblock Feb 5, 2015

Contributor

Merged.

Contributor

dblock commented Feb 5, 2015

Merged.

uqs pushed a commit to freebsd/freebsd-ports that referenced this pull request Feb 5, 2015

mi
Upgrade from 3.2.0 to 3.4.0. Include an upstream's fix made after 3.4.0
was rolled-up (intridea/hashie#277).

Sponsored by:	http://sybpipe.com/


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@378479 35697150-7ecd-e111-bb59-0022644237b5

uqs pushed a commit to freebsd/freebsd-ports that referenced this pull request Feb 5, 2015

jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Jun 9, 2015

taca
Update ruby-hashie to 3.4.2.
## 3.4.2 (6/2/2015)

* [#292](intridea/hashie#292): Removed `Mash#id` and `Mash#type` - [@jrochkind](https://github.com/jrochkind).
* [#297](intridea/hashie#297): Extracted `Trash`'s behavior into a new `Dash::PropertyTranslation` extension - [@michaelherold](https://github.com/michaelherold).

## 3.4.1

* [#269](intridea/hashie#272): Added Hashie::Extensions::DeepLocate - [@msievers](https://github.com/msievers).
* [#270](intridea/hashie#277): Fixed ArgumentError raised when using IndifferentAccess and HashWithIndifferentAccess - [@gardenofwine](https://github.com/gardenofwine).
* [#281](intridea/hashie#281): Added #reverse_merge to Mash to override ActiveSupport's version - [@mgold](https://github.com/mgold).
* [#282](intridea/hashie#282): Fixed coercions in a subclass accumulating in the superclass - [@maxlinc](https://github.com/maxlinc), [@martinstreicher](https://github.com/martinstreicher).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment