Sha256: a2f46978f88c47d646e106159d9a8f0178b36029cf5d1c4fcaea5f4abe21609e

Contents?: true

Size: 874 Bytes

Versions: 18

Compression:

Stored size: 874 Bytes

Contents

#
# A Component is a part of an Item; the principal content-bearing repository resource.
#
# Examples: Page of a book, track of a recording, etc.
#
class Component < Ddr::Models::Base

  include Ddr::Models::HasContent
  include Ddr::Models::HasMultiresImage
  include Ddr::Models::HasStructMetadata

  belongs_to :parent, :property => :is_part_of, :class_name => 'Item'
  belongs_to :target, :property => :has_external_target, :class_name => 'Target'

  after_save :index_parent, if: :has_extracted_text?, unless: "parent.nil?"

  alias_method :item, :parent
  alias_method :item=, :parent=

  def collection
    self.parent.parent rescue nil
  end

  def collection_uri
    self.collection.internal_uri rescue nil
  end

  def publishable?
    parent.present? && parent.published?
  end

  def index_parent
    Resque.enqueue(Ddr::Jobs::UpdateIndex, parent_id)
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ddr-models-2.6.2 app/models/component.rb
ddr-models-2.6.1 app/models/component.rb
ddr-models-2.6.0 app/models/component.rb
ddr-models-2.6.0.rc4 app/models/component.rb
ddr-models-2.6.0.rc3 app/models/component.rb
ddr-models-2.6.0.rc2 app/models/component.rb
ddr-models-2.6.0.rc1 app/models/component.rb
ddr-models-2.5.3 app/models/component.rb
ddr-models-2.5.2 app/models/component.rb
ddr-models-2.5.1 app/models/component.rb
ddr-models-2.5.0 app/models/component.rb
ddr-models-2.5.0.rc1 app/models/component.rb
ddr-models-2.4.16 app/models/component.rb
ddr-models-2.4.15 app/models/component.rb
ddr-models-2.4.14 app/models/component.rb
ddr-models-2.4.13 app/models/component.rb
ddr-models-2.4.12 app/models/component.rb
ddr-models-2.4.11 app/models/component.rb