-
Notifications
You must be signed in to change notification settings - Fork 1
/
contributor.rb
33 lines (26 loc) · 1.21 KB
/
contributor.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Contributor < ActiveFedora::Base
include HydraDurham::PropertyWithRelevance
type ::RDF::Vocab::DC.Agent
belongs_to :contributorable, predicate: ::RDF::URI.new('http://collections.durham.ac.uk/ns#contributor_to'), class_name: 'ActiveFedora::Base'
property :contributor_name, predicate: ::RDF::Vocab::FOAF.name do |index|
index.as :stored_searchable
end
property_with_relevance :affiliation, predicate: ::RDF::URI.new('http://collections.durham.ac.uk/ns#contributor_affiliation') do |index|
index.as :stored_searchable
end
property :role, predicate: ::RDF::URI.new('http://collections.durham.ac.uk/ns#contributor_role') do |index|
index.as :stored_searchable
end
property :order, predicate: ::RDF::URI.new('http://collections.durham.ac.uk/ns#contributor_order') do |index|
index.as :stored_searchable
end
def to_s
string = ""
string += contributor_name.any? { |string| string.strip.length > 0 } ? contributor_name.first + " " : ""
string += affiliation.any? { |string| string.strip.length > 0 } ? "(" + affiliation.join('; ') + ")" : ""
string.strip
end
def to_hash
{ contributor_name: contributor_name.to_a, affiliation: affiliation.to_a, role: role.to_a }
end
end