code4lib / ruby-oai

a Ruby library for building OAI-PMH clients and servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redo "sets" in ActiveRecord::Wrapper

jrochkind opened this issue · comments

ActiveRecord::Wrapper has some kind of built-in implementation for providing oai-pmh "sets".

But it is non-documented, and very confusing. It seems to be based on assuming that you will organize your records into sets using an actual rdbms fk/pk association (and corresponding ActiveRecord association), and/or with a String "set" column/attribute in your record table.

This seems not flexible enough, and making too many assumptions. The code is also somewhat convoluted, making lots of assumptions about your Models and making guesses. I was unable to figure out how to make tests even exersizing some paths in the code.

See eg https://github.com/code4lib/ruby-oai/blob/master/lib/oai/provider/model/activerecord_wrapper.rb#L91-L118

We should deprecate all the existing "set" stuff. And provide a new set implementation where the sets are defined on the Wrapper, rather than making assumptions about the model. They can probably conveniently make use of ActiveRecord "scopes" (methods that return relations) for the simple cases.

It should not require any additional methods (or db attributes/relationships) be added to your AR models, you should do the configuration in the wrapper class (and/or a custom sub-class of the wrapper class?)

This will probably not be done before 1.0.

See #9, #49, #66.