Sha256: 272a2a77105759824f5d46d90808693c5deede0bf4c6319ab77e5d01e04c13b4

Contents?: true

Size: 845 Bytes

Versions: 3

Compression:

Stored size: 845 Bytes

Contents

module CurationConcern
  module WithRelatedWorks
    extend ActiveSupport::Concern

    included do
      # Should use somethign like http://purl.org/dc/elements/1.1/relation
      # -- waiting for ability to modify AF predicates (which is in another branch right now).  Using :has_member until then.
      has_and_belongs_to_many :related_works, property: :has_member, class_name:"ActiveFedora::Base"
      has_many :referenced_by_works, property: :has_member, class_name:"ActiveFedora::Base"

      #attr_accessible :related_work_tokens
      accepts_nested_attributes_for :related_works, :allow_destroy => true

      def related_work_tokens=(tokens)
        self.related_work_ids = CurationConcern::Model.ids_from_tokens(tokens)
      end

      def related_work_tokens
        self.related_work_ids.join(", ")
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curate-0.5.1 app/repository_models/curation_concern/with_related_works.rb
curate-0.5.0 app/repository_models/curation_concern/with_related_works.rb
curate-0.4.2 app/repository_models/curation_concern/with_related_works.rb