Class: Person
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.
Constant Summary
collapse
- GRAVATAR_URL =
"//www.gravatar.com/avatar/"
Instance Attribute Summary collapse
Instance Method Summary
collapse
ids_from_tokens
#as_json, #as_rdf_object, #to_partial_path
#human_readable_type
#noid, #to_key, #to_param
#exists?
Instance Attribute Details
#mime_type ⇒ Object
Returns the value of attribute mime_type.
17
18
19
|
# File 'app/repository_models/person.rb', line 17
def mime_type
@mime_type
end
|
Instance Method Details
#add_profile_image(file) ⇒ Object
90
91
92
93
94
|
# File 'app/repository_models/person.rb', line 90
def add_profile_image(file)
self.content.content = file
self.mime_type = file.content_type
generate_derivatives
end
|
#can_be_member_of_collection?(collection) ⇒ Boolean
107
108
109
|
# File 'app/repository_models/person.rb', line 107
def can_be_member_of_collection?(collection)
false
end
|
#date_uploaded ⇒ Object
50
51
52
|
# File 'app/repository_models/person.rb', line 50
def date_uploaded
Time.new(create_date).strftime("%Y-%m-%d")
end
|
#first_name ⇒ Object
54
55
56
|
# File 'app/repository_models/person.rb', line 54
def first_name
name_parser.given
end
|
#gravatar_link ⇒ Object
96
97
98
99
100
101
|
# File 'app/repository_models/person.rb', line 96
def gravatar_link
return @gravatar_link unless @gravatar_link.blank?
@gravatar_link = File.join(GRAVATAR_URL, email_hash(self.email), "?s=300")
@gravatar_link += "&d=" + File.join(GRAVATAR_URL, email_hash(self.alternate_email), "?s=300") unless self.alternate_email.blank?
@gravatar_link
end
|
#last_name ⇒ Object
58
59
60
|
# File 'app/repository_models/person.rb', line 58
def last_name
name_parser.family
end
|
#name_parser ⇒ Object
62
63
64
|
# File 'app/repository_models/person.rb', line 62
def name_parser
Namae.parse(self.name).first
end
|
#representative ⇒ Object
80
81
82
|
# File 'app/repository_models/person.rb', line 80
def representative
to_param
end
|
#representative_image_url ⇒ Object
103
104
105
|
# File 'app/repository_models/person.rb', line 103
def representative_image_url
self.thumbnail.content.present? ? generate_thumbnail_url : gravatar_link
end
|
#to_s ⇒ Object
84
85
86
|
# File 'app/repository_models/person.rb', line 84
def to_s
name || "No Title"
end
|
#to_solr(solr_doc = {}, opts = {}) ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'app/repository_models/person.rb', line 70
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[Solrizer.solr_name('representative', :stored_searchable)] = self.representative
solr_doc[Solrizer.solr_name('representative_image_url', :stored_searchable)] = self.representative_image_url
solr_doc
end
|
#user ⇒ Object
66
67
68
|
# File 'app/repository_models/person.rb', line 66
def user
persisted? ? User.where(repository_id: pid).first : nil
end
|