Class: Hyrax::Arkivo::Actor
- Inherits:
-
Object
- Object
- Hyrax::Arkivo::Actor
- Defined in:
- lib/hyrax/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/hyrax/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/hyrax/arkivo/actor.rb', line 12 def item @item end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
12 13 14 |
# File 'lib/hyrax/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 33 34 35 |
# File 'lib/hyrax/arkivo/actor.rb', line 19 def create_work_from_item work = Hyrax.primary_work_type.new work_actor = Hyrax::CurationConcern.actor create_attrs = attributes.merge(arkivo_checksum: item['file']['md5']) env = Actors::Environment.new(work, current_ability, create_attrs) raise "Unable to create work. #{work.errors.}" unless work_actor.create(env) file_set = ::FileSet.new file_actor = ::Hyrax::Actors::FileSetActor.new(file_set, user) file_actor. file_set.label = item['file']['filename'] file_actor.create_content(file) # item['file']['contentType'] file_actor.attach_to_work(work) work end |
#destroy_work(work) ⇒ Object
49 50 51 |
# File 'lib/hyrax/arkivo/actor.rb', line 49 def destroy_work(work) work.destroy end |
#update_work_from_item(work) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hyrax/arkivo/actor.rb', line 37 def update_work_from_item(work) work_actor = Hyrax::CurationConcern.actor work_attributes = default_attributes.merge(attributes).merge(arkivo_checksum: item['file']['md5']) env = Actors::Environment.new(work, current_ability, work_attributes) work_actor.update(env) file_set = work.file_sets.first file_actor = ::Hyrax::Actors::FileSetActor.new(file_set, user) file_actor.update_content(file) work end |