Class: NaranyaEcm::Content

Inherits:
Object
  • Object
show all
Includes:
AASM, AASM::Persistence::NContentRestPersistence, Behaviors::MediaMethods, Behaviors::Timestampable, Search::Methods
Defined in:
lib/naranya_ecm/models/content.rb

Overview

Represents a Content unit in the Naranya CaaS Service

A content unit is made of by a list of some required attributes, along with any non-required attributes.

Attributes List

Required Attributes

In order to create a Content Unit, the Content Object should contain at least the following attributes:

  • lifecycle_name: Indicates whether the Content object follows a simple lifecycle, a validatable lifecycle (can’t publish without some sort of editorial validation first), or any other significant lifecycle.

  • title_translations: At least one localized title is required. This attribute is a Hash-like object, requiring the locale name as a key, and the localized string as value.

  • author: This string represents the name of the author of the content.

Other significant attributes

The Naranya CaaS Service is prepared to manage and gives meaning to the following attributes:

  • type: The type of content. Aids the client application in determining how to display and manage the content.

  • description_translations: Localizable descriptions of the Content.

  • content_rating:

  • keywords: Array containing a list of keywords

  • main_url: The main URL pointing to the content AS DISPLAYED BY THE CLIENT APP.

Associations

  • category:

  • versions:

  • current_version:

  • latest_version:

  • media_resources:

Instance Method Summary collapse

Methods included from AASM::Persistence::NContentRestPersistence

included

Methods included from Behaviors::MediaMethods

#detect_media_by_roles, #detect_media_url_by_roles, #find_media_by_role, #find_media_url_by_role, #select_media_by_role, #select_media_by_roles, #select_media_urls_by_role, #select_media_urls_by_roles

Methods included from Search::Methods

#merge_search_hit_data

Instance Method Details

#authorObject

:attr: author

Author: The name of the user who created this content.



122
# File 'lib/naranya_ecm/models/content.rb', line 122

field :author, type: String

#categoryObject

:attr: category :category: Associations

The category to which the Content belongs.



138
# File 'lib/naranya_ecm/models/content.rb', line 138

belongs_to :category

#content_ratingObject

:attr: content_rating

Hash-like object containing all the localized content ratings, with the rating system as a Key, and the corresponding ratin object as value.



109
# File 'lib/naranya_ecm/models/content.rb', line 109

field :content_rating, type: Hash

#current_versionObject

:attr: current_version :category: Associations

The ContentVersion object marked as current. It must be published.



152
# File 'lib/naranya_ecm/models/content.rb', line 152

belongs_to :current_version, class_name: :ContentVersion

#descriptionObject

:attr: description

The localized content description that can be displayed as header, result, etc.



98
# File 'lib/naranya_ecm/models/content.rb', line 98

field :description, type: String, localize: true

#keywordsObject

:attr: keywords

Array containing a list of keywords



115
# File 'lib/naranya_ecm/models/content.rb', line 115

field :keywords, type: Array

#latest_versionObject

:attr: latest_version :category: Associations

The ContentVersion object marked as latest.



159
# File 'lib/naranya_ecm/models/content.rb', line 159

belongs_to :latest_version, class_name: :ContentVersion

#lifecycle_nameObject

:attr: lifecycle_name

Determines the lifecycle for the specific content:

  • simple: draft -> published -> deactivated

  • validatable: draft -> awaiting_acceptance -> accepted -> published -> deactivated

  • expirable: draft -> published -> expired/inactive



65
# File 'lib/naranya_ecm/models/content.rb', line 65

field :lifecycle_name, type: String, default: -> { 'simple' }

#lifecycle_stateObject

:method: deactivate! :call-seq:

deactivate! => true or Error

Same as #deactivate, but raises an error if the transition did not complete.



79
# File 'lib/naranya_ecm/models/content.rb', line 79

field :lifecycle_state, type: String, default: -> { :draft }

#main_urlObject

:attr: main_url

Main URL: The URL that should be used to render or display the content.



130
# File 'lib/naranya_ecm/models/content.rb', line 130

field :main_url, type: String

#media_resourcesObject

:attr: media_resources :category: Associations

A list of MediaResource objects associated directly to the Content.



166
# File 'lib/naranya_ecm/models/content.rb', line 166

has_many :media_resources, class_name: :MediaResource, inverse_of: :content

#simple_lifecycle?Boolean

:method: simple_lifecycle? :call-seq:

simple_lifecycle? => true or false

Shows whether the Content object has a simple lifecycle.

Returns:

  • (Boolean)


290
291
292
# File 'lib/naranya_ecm/models/content.rb', line 290

def simple_lifecycle?
  self.lifecycle_name == 'simple'
end

#titleObject

:attr: title

The content title that can be displayed as header, result, etc.



86
# File 'lib/naranya_ecm/models/content.rb', line 86

field :title, type: String, localize: true

#typeObject

:attr: type

Describes the main type of the content - App, Note, etc.



56
# File 'lib/naranya_ecm/models/content.rb', line 56

field :type, type: String

#validatable_lifecycle?Boolean

:method: validatable_lifecycle? :call-seq:

validatable_lifecycle? => true or false

Shows whether the Content object has a validatable lifecycle.

Returns:

  • (Boolean)


300
301
302
# File 'lib/naranya_ecm/models/content.rb', line 300

def validatable_lifecycle?
  self.lifecycle_name == 'validatable'
end

#versionsObject

:attr: versions :category: Associations

A list of ContentVersion objects corresponding to changes in a versionable content.



145
# File 'lib/naranya_ecm/models/content.rb', line 145

has_many :versions, class_name: :ContentVersion