Module: ActiveData::Model::Callbacks

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_data/model/callbacks.rb

Overview

Callbacks for ActiveData::Model lifecycle

Provides ActiveModel callbacks support for lifecycle actions.

class Book
  include ActiveData::Model

  attribute :id, Integer
  attribute :title, String

  define_save do
    REDIS.set(id, attributes.to_json)
  end

  define_destroy do
    REDIS.del(instance.id)
  end

  after_initialize :setup_id
  before_save :do_something
  around_update do |&block|
    ...
    block.call
    ...
  end
  after_destroy { ... }
end

Defined Under Namespace

Modules: PrependMethods