|
#--
|
|
# LdapShadows, a Medium-level LDAP Access Library and Tool.
|
|
# Copyright (c) 2009-2010 Marc Dequènes (Duck) <Duck@DuckCorp.org>
|
|
#
|
|
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
#++
|
|
|
|
|
|
module LdapShadows
|
|
module Elements
|
|
module LdapElement
|
|
def self.included(base)
|
|
base.extend(ClassMethods)
|
|
end
|
|
|
|
module ClassMethods
|
|
# initializers
|
|
def cast
|
|
if @cast_done
|
|
raise_error _("element '%s' already initialized") % self.handle
|
|
end
|
|
@cast_done = true
|
|
end
|
|
def cast_relations
|
|
if @cast_rel_done
|
|
raise_error _("element '%s' already post-initialized") % self.handle
|
|
end
|
|
@cast_rel_done = true
|
|
end
|
|
|
|
# default empty hooks
|
|
def hook_before_create(item); end
|
|
def hook_before_modify(item); end
|
|
def hook_before_delete(item); end
|
|
def hook_after_create(item); end
|
|
def hook_after_modify(item); end
|
|
def hook_after_delete(item); end
|
|
|
|
protected
|
|
|
|
def raise_error(msg)
|
|
raise ProcessingError, msg
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
require 'ldap_shadows/elements/object'
|
|
require 'ldap_shadows/elements/aspect'
|