This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
README | Mon Sep 14 12:39:54 -0700 2009 | |
| |
init.rb | Thu Sep 10 06:07:43 -0700 2009 | |
| |
lib/ | Thu Sep 10 20:42:28 -0700 2009 | |
| |
spec/ | Thu Sep 10 20:42:28 -0700 2009 |
README
# StiFactory # # StiFactory converts the #new method of an ActiveRecord class into a subclass-aware factory method. # The factory returns a new instance of the superclass or subclass based on the presence of the # inheritance_column in the attribute list when #new is called. If the value of the # inheritance_column attribute is a valid subclass of the superclass then a new instance of the # subclass will be returned, otherwise a new instance of the superclass will be returned. # # The intention for this is to allow users to select the subclass in a form and allow the corresponding # controller to build or create an instance of the subclass without having to know that STI is # involved. # # # Example: # class Vehicle < ActiveRecord::Base # self.inheritance_column = 'vehicle_type' # has_sti_factory # end # # class Car < Vehicle; end # class Truck < Vehicle; end # class MonsterTruck < Truck; end # # Vehicle.new # #<Vehicle id: nil, vehicle_type: nil, ...> # # Vehicle.new :vehicle_type => 'Truck' # #<Truck id: nil, vehicle_type: 'Truck', ...> # # Vehicle.new :vehicle_type => 'MonsterTruck' # #<MonsterTruck id: nil, vehicle_type: 'MonsterTruck', ...> # ############################################################################ Koinonia::StiFactory - should provide an array of subclass names - should include the base class name in the list of subclass names Koinonia::StiFactory with the default inheritance column when instantiating a new object - should return the subclass named in the type attribute if it is a valid subclass - should return the specified class if no type attribute is supplied - should return the specified class if the supplied type attribute is a valid subclass of the base class Koinonia::StiFactory with the default inheritance column when creating a new object - should persist an instance of the subclass named in the type attribute - should persist an instance of the specified class if no type attribute is supplied - should persist the specified class if the value supplied in the type attribute is not a valid subclass of the base class Koinonia::StiFactory with a non-standard inheritance column when instantiating a new object - should return the subclass named in the type attribute if it is a valid subclass - should return the specified class if no type attribute is supplied - should return the specified class if the supplied type attribute is a valid subclass of the base class Koinonia::StiFactory with a non-standard inheritance column when creating a new object - should persist an instance of the subclass named in the type attribute - should persist an instance of the specified class if no type attribute is supplied - should persist the specified class if the value supplied in the type attribute is not a valid subclass of the base class







