Class: CitationTopic

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::IsData
Defined in:
app/models/citation_topic.rb

Overview

A citation topic links a Topic to a Citation. It is the assertion that a Citation contains information on a specific topic for the Citations subject. For example:

Otu Citation (Source) CitationTopic Topic (= ControlledVocabularyTerm of type “Topic”) Aus has Citation Smith (1920), with CitationTopics “Biology” on pages 21,22.

This set of data asserts that the concept of Aus, an OTU, is circumscribed/described in full or part in Smith (1920), and that one of the subjects of that circumscription is its “Biology”, specifically found on pages 21,22.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#pagesString

Returns the pages that the specific Topic is listed on.

Returns:

  • (String)

    the pages that the specific Topic is listed on



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/citation_topic.rb', line 26

class CitationTopic < ApplicationRecord

  include Housekeeping
  include Shared::IsData

  belongs_to :topic, inverse_of: :citation_topics
  belongs_to :citation, inverse_of: :citation_topics
  has_one :source, through: :citation, inverse_of: :topics

  # DO NOT INCLUDE (borks accepts_nested_attributes), handled with not null in DB
  # validates_presence_of :topic_id  :citation_id

  validates_uniqueness_of :topic_id, scope: :citation_id
  accepts_nested_attributes_for :topic, allow_destroy: true, reject_if: :reject_topic

  protected

  def reject_topic(attributed)
    attributed['name'].blank? || attributed['definition'].blank?
  end

end

#project_idInteger

the project ID

Returns:

  • (Integer)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/citation_topic.rb', line 26

class CitationTopic < ApplicationRecord

  include Housekeeping
  include Shared::IsData

  belongs_to :topic, inverse_of: :citation_topics
  belongs_to :citation, inverse_of: :citation_topics
  has_one :source, through: :citation, inverse_of: :topics

  # DO NOT INCLUDE (borks accepts_nested_attributes), handled with not null in DB
  # validates_presence_of :topic_id  :citation_id

  validates_uniqueness_of :topic_id, scope: :citation_id
  accepts_nested_attributes_for :topic, allow_destroy: true, reject_if: :reject_topic

  protected

  def reject_topic(attributed)
    attributed['name'].blank? || attributed['definition'].blank?
  end

end

#topic_idInteger

Returns the Topic in the specific citation.

Returns:

  • (Integer)

    the Topic in the specific citation



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/citation_topic.rb', line 26

class CitationTopic < ApplicationRecord

  include Housekeeping
  include Shared::IsData

  belongs_to :topic, inverse_of: :citation_topics
  belongs_to :citation, inverse_of: :citation_topics
  has_one :source, through: :citation, inverse_of: :topics

  # DO NOT INCLUDE (borks accepts_nested_attributes), handled with not null in DB
  # validates_presence_of :topic_id  :citation_id

  validates_uniqueness_of :topic_id, scope: :citation_id
  accepts_nested_attributes_for :topic, allow_destroy: true, reject_if: :reject_topic

  protected

  def reject_topic(attributed)
    attributed['name'].blank? || attributed['definition'].blank?
  end

end

Instance Method Details

#reject_topic(attributed) ⇒ Object (protected)



43
44
45
# File 'app/models/citation_topic.rb', line 43

def reject_topic(attributed)
  attributed['name'].blank? || attributed['definition'].blank?
end