A simple solution for adding inheritable attributes to your Rails models
License
heimidal/ancestree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Ancestree ========= Ancestree is a simple Rails 3 plugin that makes it easy to automatically inherit attributes from a parent object. Ancestree makes a few assumptions about the objects that will be inheriting attributes -- namely, objects should be in a tree-like structure, with each object responding to '#parent' up the tree, with the top-level objects returning nil for parent. Example ======= Let's assume you have a Node model in your Rails app and that Node objects each have a parent. You want Nodes to be "disabled" if it or any of its parents are disabled: class Node < ActiveRecord::Base include InheritAncestorAttributes belongs_to :parent, :class_name => 'Node' inherit_ancestor_attributes :disabled? end Copyright (c) 2010 Brian Rose, released under the MIT license
About
A simple solution for adding inheritable attributes to your Rails models
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published