Match classes without to_s conversions. #8173

Merged
merged 1 commit into from Nov 11, 2012

Projects

None yet

3 participants

@nikitug

There is no need in value_under_case.class.to_s conversion since case already matches classes with Class === value_under_case.

@nikitug nikitug Match classes without to_s conversions.
There is no need in `value_under_case.class.to_s` conversion since case already matches classes with `Class === value_under_case`.
d2abfcb
@carlosantoniodasilva carlosantoniodasilva commented on the diff Nov 11, 2012
...pport/lib/active_support/core_ext/hash/conversions.rb
if value['type'] == 'array'
_, entries = Array.wrap(value.detect { |k,v| not v.is_a?(String) })
if entries.nil? || (c = value['__content__'] && c.blank?)
[]
else
- case entries.class.to_s # something weird with classes not matching here. maybe singleton methods breaking is_a?
- when 'Array'
+ case entries # something weird with classes not matching here. maybe singleton methods breaking is_a?
@carlosantoniodasilva
carlosantoniodasilva Nov 11, 2012

Wonder about this comment, maybe it's related to the to_s conversion here?

@nikitug
nikitug Nov 11, 2012

Actually this comment was added in @9e44614, I do not think we need it anymore.

@carlosantoniodasilva
carlosantoniodasilva Nov 11, 2012
@carlosantoniodasilva carlosantoniodasilva merged commit f9dc917 into rails:master Nov 11, 2012
@carlosantoniodasilva
Ruby on Rails member

Thanks.

@steveklabnik
Ruby on Rails member

This method is a monster, and I was looking at refactoring it the other day. I wanted to do exactly this as step 1. Good job! 👍

@nikitug

@steveklabnik yep, this place deserves to be refactored :hurtrealbad:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment