Sha256: ad621419effac979952e18be1402b5b4d2d34de93c346bd7c27ccd3afeedd926

Contents?: true

Size: 923 Bytes

Versions: 19

Compression:

Stored size: 923 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,
             predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf,
             class_name: "Item"

  belongs_to :target,
             predicate: ::RDF::URI("http://www.loc.gov/mix/v20/externalTarget#hasExternalTarget"),
             class_name: "Target"

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

  def collection
    self.parent.parent rescue nil
  end

  def collection_id
    collection.id 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

19 entries across 19 versions & 1 rubygems

Version Path
ddr-models-3.0.8 app/models/component.rb
ddr-models-3.0.7 app/models/component.rb
ddr-models-3.0.6 app/models/component.rb
ddr-models-3.0.5 app/models/component.rb
ddr-models-3.0.4 app/models/component.rb
ddr-models-3.0.3 app/models/component.rb
ddr-models-3.0.2 app/models/component.rb
ddr-models-3.0.1 app/models/component.rb
ddr-models-3.0.0 app/models/component.rb
ddr-models-3.0.0.rc6 app/models/component.rb
ddr-models-3.0.0.rc5 app/models/component.rb
ddr-models-3.0.0.rc4 app/models/component.rb
ddr-models-3.0.0.rc3 app/models/component.rb
ddr-models-3.0.0.rc2 app/models/component.rb
ddr-models-3.0.0.rc1 app/models/component.rb
ddr-models-3.0.0.beta.22 app/models/component.rb
ddr-models-3.0.0.beta.21 app/models/component.rb
ddr-models-3.0.0.beta.20 app/models/component.rb
ddr-models-3.0.0.beta.18 app/models/component.rb