Rick has just contributed some new code that extends ActiveFedora in useful ways. Among other things, he added a has_datastream model method and added the long-absent support for deleting relationships. Incorporating his code has precipitated some ideas about how to make the code base more readable & maintainable, at least where it is dealing with content modeling stuff.
Currently, the support for content modeling type stuff (has_metadata, has_relationship, etc.) is sprinkled all around in the code base. I think we should put all of that stuff into a directory called active_fedora/model/ and modify the current ActiveFedora::Model module to inject all of that content model-derived functionality when you include it in a class.
At first pass, I'm thinking we should create these files:
active_fedora/model/datastream_modeler.rb
active_fedora/model/relationship_modeler.rb
active_fedora/model/metadata_modeler.rb
These would define ActiveFedora::Model::DatastreamModeler, ActiveFedora::Model::RelationshipModeler, and ActiveFedora::Model::MetadataModeler, which would provide class methods like has_metadata as well as any associated instance methods like metadata_streams. Then we could add these lines to active_fedora/model.rb:
self.included(klass)
klass.send(:include, ActiveFedora::Model:: DatastreamModeler)
klass.send(:include, ActiveFedora::Model::RelationshipModeler)
klass.send(:include, ActiveFedora::Model:: MetadataModeler)
end
This would ensure that ActiveFedora::Base will inherit all of those behaviors when it calls "include ActiveFedora::Model" .
Any thoughts?
Matt Zumwalt
MediaShelf, LLC