Project

ancestree

0.0
No commit activity in last 3 years
No release in over 3 years
A Rails 3.x plugin that makes inheriting properties simple.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.11.0

Runtime

 Project Readme
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