Module: Pipeline::TransactionalAttribute

Defined in:
lib/pipeline/core_ext/transactional_attribute.rb

Overview

Extends ActiveRecord::Base to provide attributes that are saved in a nested transaction when updated through a setter.

NOTE: When the extended attributes are updated, the entire record is saved

Example:

class Car < ActiveRecord::Base
  transactional_attrs :state, :engine_state

  def run
    self.engine_state = :on if self.state == :on
  end
end

car = Car.new
car.state = :on # this will save the record in a transaction
car.run # Record will be saved again, since #run updates :engine_state

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



20
21
22
# File 'lib/pipeline/core_ext/transactional_attribute.rb', line 20

def self.included (base)
  base.extend(ClassMethods)
end