Module: CocinaDisplay::Concerns::ContentType

Included in:
CocinaDisplay::CocinaRecord, RelatedResource
Defined in:
lib/cocina_display/concerns/content_type.rb

Overview

Methods related to the content type of a Cocina object.

Instance Method Summary collapse

Instance Method Details

#collection? ⇒ Boolean

True if the object is a collection.

Returns:

  • (Boolean)


16
17
18
# File 'lib/cocina_display/concerns/content_type.rb', line 16

def collection?
  content_type == "collection"
end

#content_type ⇒ String?

SDR content type of the object.

Examples:

record.content_type #=> "image"

Returns:

  • (String, nil)

See Also:



10
11
12
# File 'lib/cocina_display/concerns/content_type.rb', line 10

def content_type
  cocina_doc["type"]&.delete_prefix("https://cocina.sul.stanford.edu/models/")
end