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.

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(env) ⇒ Boolean

Returns true if update was successful.

Parameters:

Returns:

  • (Boolean)

    true if update was successful


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

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