Don't call super when Mash doesn't have id or type #57

Merged
merged 3 commits into from Oct 26, 2012

Projects

None yet

5 participants

@steved
steved commented Sep 1, 2012

Ruby 1.8 has an Object#id method that is called when the
Mash doesn't have an id key. This causes unexpected failures since
there is no id key-value, but Mash is still returning a value. If the
object_id is needed just use #object_id or #id

(Same with type -> use class)

Steven Davidovitz don't try and call Object#id when calling Mash#id
Ruby 1.8 has an Object#id method that is called when the
Mash doesn't have an id key. This causes unexpected failures since
there is no id key-value, but Mash is still returning a value. If the
object_id is needed just use Object#object_id or Object#__id__

(Same with type -> class)
d433d8b
@grosser
grosser commented Sep 1, 2012

👍

@etiennebarrie

Same problem here, with object_id this time (using 1.2.0).

Hashie::Mash.new('object_id' => 42).object_id == 42 # => false

The Instagram API for example uses object_id: http://instagram.com/developer/realtime/.
Simplest workaround is using mash[:object_id].

Steven David... added some commits Sep 4, 2012
@steved
steved commented Sep 4, 2012

Added object_id exception as well since id is still usable.

@jch
jch commented Oct 12, 2012

@steved555 this looks great! Thanks for the pull and the easy to understand tests. 🍻

@grosser
grosser commented Oct 26, 2012

@intridea can we get this merged ?

@mbleigh mbleigh merged commit f7adbf6 into intridea:master Oct 26, 2012
@steved steved added a commit to zendesk/zendesk_api_client_rb that referenced this pull request Dec 23, 2015
@steved steved remove override 20e73e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment