STI hiding attributes

I’ve written an extension to AR to allow hiding of attributes(aka
columns) in AR objects. If there’s interest in it I’ll roll it up
into a plugin. Here’s an example:

(straight from Agile Web Dev)

The table

create table people (
id int not null auto_increment,
type varchar(20) not null,

/* common attributes */
name varchar(100) not null,
email varchar(100) not null,

/* attributes for type = Customer */
balance decimal(10,2),

/* attributes for type = Employee */
reports_to int,
dept int,

/* attributes for type = Manager /
– none – */

class Person < ActiveRecord::Base

class Customer < Person
hides_attribute :reports_to, :dept

class Employee < Person
hides_attribute :balance

class Manager < Employee
hides_attribute :reports_to, :dept

The extension will put out the attributes specified in hides_attribute
so a Customer
object will no longer respond to reports_to, reports_to=, dept, or dept=

So any interest?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs