Class: Hyrax::Actors::CollectionsMembershipActor

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

Overview

Adds membership to and removes membership from collections. This decodes parameters that follow the rails nested parameters conventions:

Examples:

a collections attribute hash

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

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

#create(env) ⇒ Boolean

Returns true if create was successful.

Parameters:

Returns:

  • (Boolean)

    true if create was successful



16
17
18
19
# File 'app/actors/hyrax/actors/collections_membership_actor.rb', line 16

def create(env)
  extract_collection_id(env)
  assign_nested_attributes_for_collection(env) && next_actor.create(env)
end

#update(env) ⇒ Boolean

Returns true if update was successful.

Parameters:

Returns:

  • (Boolean)

    true if update was successful



23
24
25
# File 'app/actors/hyrax/actors/collections_membership_actor.rb', line 23

def update(env)
  assign_nested_attributes_for_collection(env) && next_actor.update(env)
end