class ActiveFedora::ContentModel
def self.default_model(obj)
## Returns a ruby class to use if no other class could be find to instantiate
def self.default_model(obj) ActiveFedora::Base end
def self.known_models_for(obj)
a StreamingVideo model but the application doesn't define a
application that the given object asserts (ie. if the object asserts
returns an array of the model classes that are defined in the current
def self.known_models_for(obj) models_array = [] models_asserted_by( obj ).each do |model_uri| m = uri_to_model_class(model_uri) if m models_array << m end end if models_array.empty? models_array = [default_model(obj)] end return models_array end
def self.models_asserted_by(obj)
def self.models_asserted_by(obj) obj.relationships(:has_model) end
def self.sanitized_class_name(klass)
def self.sanitized_class_name(klass) klass.name.gsub(/(::)/, '_') end
def self.uri_to_model_class( uri )
Returns an ActiveFedora Model class corresponding to the given uri if one can be found.
def self.uri_to_model_class( uri ) rc = Model.from_class_uri(uri) if rc && (rc.superclass == ActiveFedora::Base || rc.ancestors.include?(ActiveFedora::Base)) rc else false end end
def initialize(attrs={})
def initialize(attrs={}) @pid_suffix = attrs.has_key?(:pid_suffix) ? attrs[:pid_suffix] : CMODEL_PID_SUFFIX @namespace = attrs.has_key?(:namespace) ? attrs[:namespace] : CMODEL_NAMESPACE super end