Changes to AS are very intrusive since they modify classes, getting something 
into AS is probably the hardest of all the libraries included in Rails. It 
doesn't mean you shouldn't try. 

If you're interested and passionate about making this change, I suggest making 
a new branch adding in the extra code to AS including tests as you normally 
would any change, then in a separate commit to the same branch clean up one or 
more of the places where you think using #transform_values could have a huge 
impact. This way anyone can easily see the value of having this method included 
in the AS codebase.

Yay or nay? I would need to see an implementation and usage to make that call. 

-- 
Richard Schneeman
http://heroku.com

@schneems (http://twitter.com/schneems)




On Monday, January 7, 2013 at 1:37 PM, Gosha Arinich wrote:

> Mapping hash keys and values is tricky in Ruby. Mapping a hash returns an 
> array, but we want a hash. Why bother coercing it every time?
> 
> To simplify that a bit, AS introduced Hash#transform_keys. I have noticed 
> Rails source base still uses a few tricks to map values of hashes in 
> different places. Additionally, applications built on top of Rails might 
> experience the need to map hash values as well.
> 
> That said, I propose to extend Hash to allow this, in manner similar to 
> #transform_keys:
> 
> > { a: 1, b: 2 }.transform_keys { |key| :"_#{key}" } # => { :_a => 1, :_b => 
> > 2 }
> > 
> > { a: 1, b: 2 }.transform_values { |val| val ** 2 } # => { :a => 1, :b => 4 }
> 
> Yay or nay? 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/rubyonrails-core/-/jE9nOBXywWkJ.
> To post to this group, send email to rubyonrails-core@googlegroups.com 
> (mailto:rubyonrails-core@googlegroups.com).
> To unsubscribe from this group, send email to 
> rubyonrails-core+unsubscr...@googlegroups.com 
> (mailto:rubyonrails-core+unsubscr...@googlegroups.com).
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-core?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to