Class: Hyperactive::Record::Bass

Inherits:
Object
  • Object
show all
Includes:
Index::Indexable, Persistent, Transactions::Accessors
Defined in:
lib/hyperactive/record.rb,
lib/hyperactive/record.rb

Overview

A convenient base class to inherit when you want the basic utility methods provided by for example ActiveRecord::Base *hint hint*.

NB: When an instance is created you will actually have a copy within your local machine which is not what you usually want. Every other time you fetch it using a select or other method you will instead receive a proxy object to the database. This means that nothing you do to it at that point will be persistent or even necessarily have a defined result. Therefore: do not use the instantiated object, instead call my_instance.create or MyClass.get_instance to get a proxy to the object stored into the database.

NB: When a subclass is created with get_instance, initialize is called and then create is called and its return value returned. If you instead use get_instance_with_transaction, initialize will be called (like before) and then create with the given transaction. This means that you can not use transactions in initialize and at the same time make get_instance_with_transaction work, since the initialize method wont know about the transaction sent to get_instance_with_transaction. Of course, this can be avoided using varying degrees of ugly hack, but a simpler way is to try and make initialize not do transaction-dependant stuff, like create new Hyperactive::Record::Bass instances, but instead do that in (for example) create_hooks (See Hyperactive::Hooker::Pimp).

Method Summary

Methods included from Transactions::Accessors

append_features

Methods included from Index::Indexable

append_features

Methods included from Persistent

#<=>, append_features, #create, #destroy!, #with_transaction