projecthydra/active_fedora — pull request #391 by scande3 (2014-04-10 22:17:35+00:00)
Title: Fix belongs_to cmodel inheritance.

While has_many was still working as intended, some changes to
belongs_to broke a cmodel inheritance use case. This use case was
not adequately tested corrected and I've updated the appropriate
unit test to check for the below.

Given the following setup:

class SimpleCollection < ActiveFedora::Base
has_many :objects, property: :is_part_of, class_name: 'Object'
end

class ComplexCollection < SimpleCollection
end

class Item < ActiveFedora::Base
belongs_to :collection, :property=>:is_part_of, \
:class_name=>''SimpleCollection”
end

Doing the following should work:

object = Item.new
object.collection = ComplexCollection.create
object.save!

object.collection #returns the complex collection

In our exact use case, we have “SystemCollection” and
“OAICollection” that inherit from a base “Collection”
class. Before this fix, mapping to “Collection” would
return neither despite that being in their cmodel
structure since the code was updated to only look at an
exact class match.

As no one else is using inheritance that I am aware of,
this change should not impact any other hydra heads.