Class: Sufia::Arkivo::Actor
- Inherits:
-
Object
- Object
- Sufia::Arkivo::Actor
- Defined in:
- lib/sufia/arkivo/actor.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create_work_from_item ⇒ Object
- #destroy_work(work) ⇒ Object
-
#initialize(user, item) ⇒ Actor
constructor
A new instance of Actor.
- #update_work_from_item(work) ⇒ Object
Constructor Details
#initialize(user, item) ⇒ Actor
Returns a new instance of Actor.
14 15 16 17 |
# File 'lib/sufia/arkivo/actor.rb', line 14 def initialize(user, item) @user = user @item = item end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
12 13 14 |
# File 'lib/sufia/arkivo/actor.rb', line 12 def item @item end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
12 13 14 |
# File 'lib/sufia/arkivo/actor.rb', line 12 def user @user end |
Instance Method Details
#create_work_from_item ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sufia/arkivo/actor.rb', line 19 def create_work_from_item work = Sufia.primary_work_type.new work_actor = CurationConcerns::CurationConcern.actor(work, user) create_attrs = attributes.merge(arkivo_checksum: item['file']['md5']) raise "Unable to create work. #{work.errors.messages}" unless work_actor.create(create_attrs) file_set = ::FileSet.new file_actor = ::CurationConcerns::Actors::FileSetActor.new(file_set, user) file_actor.(work) file_set.label = item['file']['filename'] file_actor.create_content(file) # item['file']['contentType'] work end |
#destroy_work(work) ⇒ Object
45 46 47 |
# File 'lib/sufia/arkivo/actor.rb', line 45 def destroy_work(work) work.destroy end |
#update_work_from_item(work) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sufia/arkivo/actor.rb', line 34 def update_work_from_item(work) (work) work_actor = CurationConcerns::CurationConcern.actor(work, user) work_attributes = attributes.merge(arkivo_checksum: item['file']['md5']) work_actor.update(work_attributes) file_set = work.file_sets.first file_actor = ::CurationConcerns::Actors::FileSetActor.new(file_set, user) file_actor.update_content(file) work end |