Re: [Rails-core] [Feature] Add support HashWithIndifferentAccess to Hash#extract!

2016-09-22 Thread richard schneeman
HashWithIndifferentAccess is EXTREMELY expensive. For some background I did a 
write up on Hashie, another object that inherits from Hash 
http://www.schneems.com/2014/12/15/hashie-considered-harmful.html

Several of the problems that apply to hashie also apply to HWIA. Basically any 
subclass of Hash is going to be slow. Here's an issue I opened in Rack which is 
closer to HWIA https://github.com/rack/rack/issues/738.

-- 
Richard Schneeman
http://schneems.com


On September 22, 2016 at 8:37:32 AM, Andrey Molchanov (neod...@gmail.com) wrote:

Hello there!
I propose to add support for class objects HashWithIndifferentAccess to method 
Hash#extract!:
before:
def extract!(*keys)
  keys.each_with_object(self.class.new) { |key, result| result[key] = 
delete(key) if has_key?(key) }
end
after:
def extract!(*keys)
  keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
  keys.each_with_object(self.class.new) { |key, result| result[key] = 
delete(key) if has_key?(key) }
end
Thanks! 
--
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


[Rails-core] [Feature] Add support HashWithIndifferentAccess to Hash#extract!

2016-09-22 Thread Andrey Molchanov
Hello there!
I propose to add support for class objects *HashWithIndifferentAccess* to 
method *Hash#extract!*:
before:

def extract!(*keys)
  keys.each_with_object(self.class.new) { |key, result| result[key] = 
delete(key) if has_key?(key) }
end

after:

def extract!(*keys)
  keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
  keys.each_with_object(self.class.new) { |key, result| result[key] = 
delete(key) if has_key?(key) }
end

Thanks! 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.