Class: Person

Inherits:
ActiveFedora::Base
  • Object
show all
Includes:
ActiveFedora::RegisteredAttributes, CurationConcern::Model
Defined in:
app/repository_models/person.rb

Overview

Person - A named singular entity; A Person may have a one to one relationship with a User. A Person is a Container.

profile: Each person has a profile which is actually just a collection that is explicitly referenced by the person using a :has_profile relationship.

Instance Method Summary collapse

Methods included from CurationConcern::Model

#as_json, #human_readable_type, ids_from_tokens, #to_partial_path

Instance Method Details

#date_uploadedObject



43
44
45
# File 'app/repository_models/person.rb', line 43

def date_uploaded
  Time.new(create_date).strftime("%Y-%m-%d")
end

#first_nameObject



47
48
49
# File 'app/repository_models/person.rb', line 47

def first_name
  name_parser.given
end

#last_nameObject



51
52
53
# File 'app/repository_models/person.rb', line 51

def last_name
  name_parser.family
end

#name_parserObject



55
56
57
# File 'app/repository_models/person.rb', line 55

def name_parser
  Namae.parse(self.name).first
end

#to_sObject



71
72
73
# File 'app/repository_models/person.rb', line 71

def to_s
  name || "No Title"
end

#to_solr(solr_doc = {}, opts = {}) ⇒ Object



63
64
65
66
67
68
69
# File 'app/repository_models/person.rb', line 63

def to_solr(solr_doc={}, opts={})
  super(solr_doc, opts)
  Solrizer.set_field(solr_doc, 'generic_type', 'Person', :facetable)
  solr_doc['read_access_group_ssim'] = 'public'
  solr_doc['has_user_bsi'] = !!User.exists?(repository_id: pid)
  solr_doc
end

#userObject



59
60
61
# File 'app/repository_models/person.rb', line 59

def user
  persisted? ? User.where(repository_id: pid).first : nil
end