Module: CurationConcern::Work
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Model
#as_json, #as_rdf_object, #can_be_member_of_collection?, #to_partial_path, #to_s
#human_readable_type
#noid, #to_key, #to_param
Class Method Details
.ids_from_tokens(tokens) ⇒ Object
Parses a comma-separated string of tokens, returning an array of ids
6
7
8
|
# File 'app/repository_models/curation_concern/work.rb', line 6
def self.ids_from_tokens(tokens)
tokens.gsub(/\s+/, "").split(',')
end
|
Instance Method Details
#add_editor(editor) ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/repository_models/curation_concern/work.rb', line 39
def add_editor(editor)
return unless editor.is_a?(Person)
self.editors << editor
self.permissions_attributes = [{name: editor.depositor, access: "edit", type: "person"}] unless self.depositor == editor.depositor
self.save!
editor.works << self
editor.save!
end
|
#add_editor_group(group) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'app/repository_models/curation_concern/work.rb', line 21
def add_editor_group(group)
return unless group.is_a?(Hydramata::Group)
self.editor_groups << group
self.permissions_attributes = [{name: group.title, access: "edit", type: "group"}]
self.save!
group.works << self
group.save!
end
|
#remove_editor(editor) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/repository_models/curation_concern/work.rb', line 48
def remove_editor(editor)
if( ( self.depositor != editor.depositor ) && ( self.editors.include?( editor ) ) )
self.editors.delete(editor)
self.edit_users = self.edit_users - [editor.depositor]
self.save!
editor.works.delete(self)
editor.save!
end
end
|
#remove_editor_group(group) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'app/repository_models/curation_concern/work.rb', line 30
def remove_editor_group(group)
return unless self.edit_groups.include?(group.title)
self.editor_groups.delete(group)
self.edit_groups = self.edit_groups - [group.title]
self.save!
group.works.delete(self)
group.save!
end
|
#to_solr(solr_doc = {}, opts = {}) ⇒ Object
15
16
17
18
19
|
# File 'app/repository_models/curation_concern/work.rb', line 15
def to_solr(solr_doc={}, opts={})
super(solr_doc, opts)
Solrizer.set_field(solr_doc, 'generic_type', 'Work', :facetable)
return solr_doc
end
|