Module: ActiveFedora::SemanticNode::ClassMethods
- Defined in:
- lib/active_fedora/semantic_node.rb
Instance Method Summary collapse
-
#relationships_desc ⇒ Hash
Return hash that persists relationship metadata defined by has_relationship calls.
Instance Method Details
#relationships_desc ⇒ Hash
Return hash that persists relationship metadata defined by has_relationship calls. If you implement a child class of ActiveFedora::Base it will inherit the relationship descriptions defined there by merging in the class instance variable values. It will also do this for any level of ancestors.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/active_fedora/semantic_node.rb', line 222 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 |