Module: Timberline::Rails::ActiveRecord

Defined in:
lib/timberline/rails/active_record.rb

Overview

Timberline::Rails::ActiveRecord will add some extra logic to your ActiveRecord models so that you can quickly and easily defer certain methods to background processing.

Although this module is primarily intended for use with ActiveRecord models, it will actually work with any class that implements the following methods:

  • primary_key - a method that returns a String representing the primary_key for this model (for ActiveRecord this is usually “id”)

  • find_by_ - a method that returns an object matching the specified primary key, or nil if it does not exist (e.g. “find_by_id”)

Examples:

using Timberline::Rails::ActiveRecord to process an email in the background

class User < ActiveRecord::Base
  include Timberline::Rails::ActiveRecord

  timberline_queue "users"

  def send_some_email
    # do stuff to send the email
  end
  delay_method :send_some_email
end

See Also:

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



30
31
32
33
34
# File 'lib/timberline/rails/active_record.rb', line 30

def self.included(klass)
  klass.class_eval do
    extend Timberline::Rails::ActiveRecord::ClassMethods  
  end
end