Class: CitationTopic

Inherits:
ActiveRecord::Base
  • Object
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 Housekeeping

#has_polymorphic_relationship?

Instance Attribute Details

- (String) pages

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
48
49
50
# File 'app/models/citation_topic.rb', line 26

class CitationTopic < ActiveRecord::Base

  include Housekeeping
  include Shared::IsData

  belongs_to :topic, inverse_of: :citation_topics
  belongs_to :citation, inverse_of: :citation_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

  # deprecated, all values are nilified
  nil_trim_attributes(:pages)

  protected

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

end

- (Integer) project_id

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
48
49
50
# File 'app/models/citation_topic.rb', line 26

class CitationTopic < ActiveRecord::Base

  include Housekeeping
  include Shared::IsData

  belongs_to :topic, inverse_of: :citation_topics
  belongs_to :citation, inverse_of: :citation_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

  # deprecated, all values are nilified
  nil_trim_attributes(:pages)

  protected

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

end

- (Integer) topic_id

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
48
49
50
# File 'app/models/citation_topic.rb', line 26

class CitationTopic < ActiveRecord::Base

  include Housekeeping
  include Shared::IsData

  belongs_to :topic, inverse_of: :citation_topics
  belongs_to :citation, inverse_of: :citation_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

  # deprecated, all values are nilified
  nil_trim_attributes(:pages)

  protected

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

end

Instance Method Details

- (Object) reject_topic(attributed) (protected)



46
47
48
# File 'app/models/citation_topic.rb', line 46

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