Class: Person
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Person
show all
- Includes:
- ActiveFedora::RegisteredAttributes, CurationConcern::Work, Hydra::Derivatives
- 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.
Constant Summary
collapse
- GRAVATAR_URL =
"//www.gravatar.com/avatar/"
Instance Attribute Summary collapse
Instance Method Summary
collapse
ids_from_tokens
#as_json, #can_be_member_of_collection?, #to_partial_path
#human_readable_type
#noid, #to_key, #to_param
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
84
85
86
87
88
|
# File 'app/repository_models/person.rb', line 84
def add_profile_image(file)
self.content.content = file
self.mime_type = file.content_type
generate_derivatives
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
90
91
92
93
94
95
|
# File 'app/repository_models/person.rb', line 90
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
|
#to_s ⇒ Object
78
79
80
|
# File 'app/repository_models/person.rb', line 78
def to_s
name || "No Title"
end
|
#to_solr(solr_doc = {}, opts = {}) ⇒ Object
70
71
72
73
74
75
76
|
# 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
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
|