active-hash / active_hash

A readonly ActiveRecord-esque base class that lets you use a hash, a Yaml file or a custom file as the datasource
MIT License
1.19k stars 178 forks source link

fix: provide a cleaner method missing error #277

Closed rgarver closed 1 year ago

rgarver commented 1 year ago

I hit a weird error that ultimately was my fault, but it exposed a use-before-initialize bug in ActiveHash::Relation#method_missing on the .scopes class_attribute. I changed the class_attribute to a class method with a memoized class variable that is lazily initialized on reference.

This is a low-impact addition.

kbrock commented 1 year ago

Will this be solved via https://github.com/active-hash/active_hash/pull/278

would prefer to not introduce the scopes variable if possible.

rgarver commented 1 year ago

Indeed, much simpler. Good catch.