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

Constant Summary

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

Instance Method Summary (collapse)

Methods inherited from Source

batch_create, batch_preview, #cited_objects, #is_bibtex?, 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

Instance Method Details

- (Object) at_least_one_person_is_provided (protected)



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

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

- (Object) authority_name



12
13
14
15
# File 'app/models/source/human.rb', line 12

def authority_name
  last_names = people.collect{|p| p.last_name}
  last_names.to_sentence(last_word_connector: ' & ', two_words_connector: ' & ')
end

- (Object) set_cached (protected)



19
20
21
# File 'app/models/source/human.rb', line 19

def set_cached
  update_column(:cached, authority_name)
end