Project

General

Profile

« Previous | Next » 

Revision 88b0bbce

Added by Marc Dequènes over 14 years ago

  • ID 88b0bbcec4c3663e669e91d18bdbc1e059816758

[cleanup] move default empty hooks aside and include them (and share them between LdapObject and LdapAspect)

View differences:

lib/ldap_shadows/aspect.rb
#++
module LdapShadows
class LdapAspect
def self.hook_before_create(shadow, item)
end
def self.hook_before_modify(shadow, item)
end
def self.hook_before_delete(shadow, item)
end
def self.hook_after_create(shadow, item)
end
require 'ldap_shadows/hooks'
def self.hook_after_modify(shadow, item)
end
def self.hook_after_delete(shadow, item)
end
protected
def self.raise_error(msg)
raise ProcessingError, msg
end
module LdapShadows
class LdapAspect
include Hooks
end
end
lib/ldap_shadows/hooks.rb
#--
# LdapShadows, a Medium-level LDAP Access Library and Tool.
# Copyright (c) 2009 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 Hooks
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# default empty hooks
def hook_before_create(shadow, item); end
def hook_before_modify(shadow, item); end
def hook_before_delete(shadow, item); end
def hook_after_create(shadow, item); end
def hook_after_modify(shadow, item); end
def hook_after_delete(shadow, item); end
protected
def self.raise_error(msg)
raise ProcessingError, msg
end
end
end
end
lib/ldap_shadows/object.rb
#++
require 'ldap_shadows/hooks'
module LdapShadows
class LdapObject < ActiveLdap::Base
include Hooks
class_inheritable_accessor :handle, :presentation, :shadow, :relations_info
ldap_mapping :prefix => '', :classes => ['top'], :scope => :sub
......
after_delete_jobs
end
def self.hook_before_create(shadow, item)
end
def self.hook_before_modify(shadow, item)
end
def self.hook_before_delete(shadow, item)
end
def self.hook_after_create(shadow, item)
end
def self.hook_after_modify(shadow, item)
end
def self.hook_after_delete(shadow, item)
end
protected
def self.raise_error(msg)
raise ProcessingError, msg
end
def before_save_jobs
check_hooks_before(:save)
check_missing_attributes

Also available in: Unified diff