include Enumerable in AR::Base?

See for include Enumerable in AR::Base · Issue #5381 · rails/rails · GitHub for background.

AR models live somewhere between simple data structure (Hash) and domain objects with arbitrarily complex behavior.#5345 introduces slice to the model API, which makes it feel more like a data structure. I propose that:

  1. AR::Base includes Enumerable
  2. Add a method to declare a list of method names that should be treated as hash keys
  3. implement each to iterate over the attributes hash with the declared methods (and their values) merged in This would effectively allow users to pass AR models to any method that operates on a Hash.