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.

The env for this actor may contain a Valkyrie::Resource or an ActiveFedora::Base model, as required by the caller.

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



22
23
24
25
26
# File 'app/actors/hyrax/actors/attach_members_actor.rb', line 22

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