Sha256: 9bd47d8a27e0286916184dea0c55d3c130f5a531a622ca622f388d6e08efe36a

Contents?: true

Size: 807 Bytes

Versions: 3

Compression:

Stored size: 807 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 index_parent
    Resque.enqueue(Ddr::Jobs::UpdateIndex, parent_id)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddr-models-2.4.10 app/models/component.rb
ddr-models-2.4.9 app/models/component.rb
ddr-models-2.4.8 app/models/component.rb