#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2006 Emencia
#
# Authors: Lafaye Philippe (RAGE2000) <lafaye@emencia.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# $Id: cleansources.py 488 2006-11-08 16:26:13Z tarek $

"""Model class for building rules class"""

class Rules(object):
    """Rules object to manage a caddy
       Basic object, take a rule object instance in init"""

    def __init__(self, rule=None):
        self.parent_rule = rule

    def rule(self, value, *args, **kwarg):
        """ standart rule, need to be overload """
        return value

    def __call__(self, value, *args, **kwarg):
        """ this method is the motor for link all the child class """
        value = self.rule(value, *args, **kwarg)
        if self.parent_rule is not None:
            value = self.parent_rule(value, *args, **kwarg)
        return value
