Class: Hyrax::Actors::AttachMembersActor

Inherits:
AbstractActor show all
Defined in:
app/actors/hyrax/actors/attach_members_actor.rb

Overview

Attach or remove child works to/from this work. This decodes parameters that follow the rails nested parameters conventions: e.g.

'work_members_attributes' => {
  '0' => { 'id' = '12312412'},
  '1' => { 'id' = '99981228', '_destroy' => 'true' }
}

The goal of this actor is to mutate the ordered_members with as few writes as possible, because changing ordered_members is slow. This class only writes changes, not the full ordered list.

TODO: Perhaps this can subsume AttachFilesActor

Instance Attribute Summary

Attributes inherited from AbstractActor

#next_actor

Instance Method Summary collapse

Methods inherited from AbstractActor

#initialize

Constructor Details

This class inherits a constructor from Hyrax::Actors::AbstractActor

Instance Method Details

#update(attributes) ⇒ Object



17
18
19
20
21
# File 'app/actors/hyrax/actors/attach_members_actor.rb', line 17

def update(attributes)
  attributes_collection = attributes.delete(:work_members_attributes)
  assign_nested_attributes_for_collection(attributes_collection) &&
    next_actor.update(attributes)
end