Sha256: e2c83886688007be57dfe648b85512cffa1c902e14ebc9e374341cea3cb79c45

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

module Ddr
  class Component < Resource

    include Captionable
    include Embargoable
    include HasContent
    include HasDerivedImage
    include HasExtractedText
    include HasMultiresImage
    include HasParent
    include Streamable

    alias_method :item_id, :parent_id
    alias_method :item, :parent

    attribute :intermediate_file, Ddr::File.optional
    attribute :target_id, Valkyrie::Types::ID.optional

    self.parent_class = Ddr::Item

    def collection
      self.parent.parent rescue nil
    end

    def collection_id
      self.collection.id rescue nil
    end

    def target
      Ddr.query_service.find_by(id: target_id) if target_id
    end

    def inherited_roles
      if has_parent?
        super | parent.policy_roles
      else
        super
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddr-core-1.17.0 app/models/ddr/component.rb
ddr-core-1.16.0 app/models/ddr/component.rb
ddr-core-1.15.0 app/models/ddr/component.rb