Module: ActiveFedora::SemanticNode::ClassMethods

Defined in:
lib/active_fedora/semantic_node.rb

Instance Method Summary collapse

Instance Method Details

#internal_uri(pid) ⇒ String

Returns a URI represented as a string.

Parameters:

  • pid (String)

    the fedora object identifier

Returns:

  • (String)

    a URI represented as a string



152
153
154
# File 'lib/active_fedora/semantic_node.rb', line 152

def internal_uri(pid)
  "info:fedora/#{pid}"
end

#pid_from_uri(uri) ⇒ String

Returns the pid component of the URI.

Parameters:

  • uri (String)

    a uri (as a string)

Returns:

  • (String)

    the pid component of the URI



158
159
160
# File 'lib/active_fedora/semantic_node.rb', line 158

def pid_from_uri(uri)
  uri.gsub("info:fedora/", "")
end

#to_class_uri(attrs = {}) ⇒ Object

Returns a suitable uri object for :has_model Should reverse Model#from_class_uri



136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/active_fedora/semantic_node.rb', line 136

def to_class_uri(attrs = {})
  if self.respond_to? :pid_suffix
    pid_suffix = self.pid_suffix
  else
    pid_suffix = attrs.fetch(:pid_suffix, ContentModel::CMODEL_PID_SUFFIX)
  end
  if self.respond_to? :pid_namespace
    namespace = self.pid_namespace
  else
    namespace = attrs.fetch(:namespace, ContentModel::CMODEL_NAMESPACE)
  end
  "info:fedora/#{namespace}:#{ContentModel.sanitized_class_name(self)}#{pid_suffix}" 
end