Class: Hyrax::Actors::TransactionalRequest

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

Overview

Wrap the stack in a database transaction. This will roll back any database actions (particularly workflow) if there is an error elsewhere in the actor stack.

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


10
11
12
13
14
# File 'app/actors/hyrax/actors/transactional_request.rb', line 10

def create(env)
  ActiveRecord::Base.transaction do
    next_actor.create(env)
  end
end

#update(env) ⇒ Boolean

Returns true if update was successful.

Parameters:

Returns:

  • (Boolean)

    true if update was successful


18
19
20
21
22
# File 'app/actors/hyrax/actors/transactional_request.rb', line 18

def update(env)
  ActiveRecord::Base.transaction do
    next_actor.update(env)
  end
end