module ActiveFedora::SemanticNode::ClassMethods

def relationships_desc

Returns:
  • (Hash) - Hash of relationship subject (:self or :inbound) mapped to nested hashs of each relationship name mapped to another hash relationship options
def relationships_desc
  #get any relationship descriptions from superclasses
  if @class_relationships_desc.nil?
    @class_relationships_desc ||= Hash[:self => {}]
    #get super classes
    super_klasses = []
    #insert in reverse order so the child overwrites anything in parent
    super_klass = self.superclass
    while !super_klass.nil?
      super_klasses.insert(0,super_klass)
      super_klass = super_klass.superclass
    end
  
    super_klasses.each do |super_klass|
      if super_klass.respond_to?(:relationships_desc)
        super_rels = super_klass.relationships_desc
        super_rels.each_pair do |subject,rels|
          @class_relationships_desc[subject] = {} unless @class_relationships_desc.has_key?(subject)
          @class_relationships_desc[subject].merge!(rels)
        end
      end
    end
  end
  @class_relationships_desc
end