Class: Source::Human

Inherits:
Source show all
Defined in:
app/models/source/human.rb

Overview

A human source can be either a single individual person or a group of people (e.g. Tom, Dick and Harry decided that this species is the same as that but haven't written it up yet.)

Constant Summary

IGNORE_IDENTICAL =
[:serial_id, :address, :annote, :booktitle, :chapter, :crossref,
:edition, :editor, :howpublished, :institution, :journal, :key,
:month, :note, :number, :organization, :pages, :publisher, :school,
:series, :title, :volume, :doi, :abstract, :copyright, :language,
:stated_year, :verbatim, :bibtex_type, :day, :year, :isbn, :issn,
:verbatim_contents, :verbatim_keywords, :language_id, :translator,
:year_suffix, :url, :author, :cached, :cached_author_string,
:cached_nomenclature_date].freeze
IGNORE_SIMILAR =
IGNORE_IDENTICAL.dup.freeze

Constants inherited from Source

ALTERNATE_VALUES_FOR

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary

Attributes inherited from Source

#abstract, #address, #annote, #author, #bibtex_type, #booktitle, #cached, #cached_author_string, #cached_nomenclature_date, #chapter, #copyright, #crossref, #day, #doi, #edition, #editor, #howpublished, #institution, #isbn, #issn, #journal, #key, #language, #language_id, #month, #note, #number, #organization, #pages, #publisher, #school, #serial_id, #series, #stated_year, #title, #translator, #type, #url, #verbatim, #verbatim_contents, #verbatim_keywords, #volume, #year, #year_suffix

Attributes included from Housekeeping::Users

#by

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Source

batch_create, batch_preview, #cited_objects, #is_bibtex?, #is_in_project?, new_from_citation, new_from_doi, #reject_project_sources

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

Methods included from Housekeeping::Timestamps

#data_breakdown_for_chartkick_recent

Methods included from Housekeeping::Users

#set_created_by_id, #set_updated_by_id

Methods included from ActiverecordUtilities

#trim_attributes

Class Method Details

+ (Scope) identical(attr)

Parameters:

  • attr (Hash)

    of matchable attributes

Returns:

  • (Scope)


38
39
40
# File 'app/models/source/human.rb', line 38

def self.identical(attr)
  Source::Human.none
end

+ (Scope) similar(attr)

TODO: Special case of Source::Human needs to check for roles of 'SourceSource' matching.

Parameters:

  • attr (Hash)

    of matchable attributes

Returns:

  • (Scope)


32
33
34
# File 'app/models/source/human.rb', line 32

def self.similar(attr)
  Source::Human.none
end

Instance Method Details

- (Ignored) at_least_one_person_is_provided (protected)

Returns:

  • (Ignored)


60
61
62
63
64
# File 'app/models/source/human.rb', line 60

def at_least_one_person_is_provided
  if people.size < 1 # size not count
    errors.add(:base, 'at least one person must be provided')
  end
end

- (String) authority_name

Returns:

  • (String)


23
24
25
26
27
# File 'app/models/source/human.rb', line 23

def authority_name
  Utilities::Strings.authorship_sentence(
    people.collect { |p| p.last_name }
  )
end

- (Scope) identical

Returns:

  • (Scope)


48
49
50
# File 'app/models/source/human.rb', line 48

def identical
  Source::Human.none
end

- (Ignored) set_cached (protected)

Returns:

  • (Ignored)


55
56
57
# File 'app/models/source/human.rb', line 55

def set_cached
  update_column(:cached, authority_name)
end

- (Scope) similar

Returns:

  • (Scope)


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

def similar
  Source::Human.none
end