flyerhzm/simple_cacheable — pull request #26 by ScotterC (2013-07-26 14:50:09+00:00)
Title: This started as a small bug and got crazy.

Alright. This started out with some silent errors within a STI class that turned into a full blown problem with any situation where Cacheable is inherited.

Demonstration:
````
class User < ActiveRecord
include Cacheable

model_cache do
# *methods
end
end

class Descandant < User

model_cache do
# inherits old methods and adds new ones
end
end
````

Cacheable did not act as expected. Child classes simply did not inherit any of the class attributes from the parent model class. This is because class_attributes were defined in the model cache class method and therefore were being reset to nil. This has been fixed by only setting them when the module is included an not in each call of `model_cache`.

The second complication was that you expect the descandant class to inherit all the parent's cached methods and then add your own. This required rejiggering how [class_attributes](http://apidock.com/rails/Class/class_attribute) were set. They needed to be merged. However, mutable objects such as Arrays & Hashes cannot simple be merged and need assignment which is how User.cached_indices and Descendant.cached_indices stay separate.

There are a lot of silent failures going on here which is why the test suite has been made more explicit. However, it should probably be taken a step further at a later point.