Module: Treequel::ContentSyncControl
Overview
A Treequel::Control module that implements the “Content Sync” control (RFC 4533)
NOTICE: This control currently doesn’t do anything, as it depends on Intermediate Responses, which the underlying Ruby-LDAP library doesn’t support (yet).
Usage
As with all Controls, you must first register the control with the Treequel::Directory object you’re intending to search:
dir = Treequel.directory( 'ldap://ldap.acme.com/dc=acme,dc=com' )
dir.register_controls( Treequel::ContentSyncControl )
Once that’s done, any Treequel::Branchset you create will have the #on_sync method:
# Build DHCP records out of all the hosts in the directory, then rebuild
# everything when a host record changes.
hosts = dir.filter( :ou => Hosts ).collection
hosts.filter( :objectClass => :ipHost ).on_sync do ||
#
end
See deveiate.org/projects/Treequel/ticket/6 Ticket: Add support for the RFC4533 Content Sync operation.
Constant Summary collapse
- OID =
The control’s OID
CONTROL_OIDS[:sync]
- SYNC_MODE_REFRESH =
Sync mode constants (from RFC4533, section 2.2)
1- SYNC_MODE_REFRESH_AND_PERSIST =
3
Constants included from Constants
Treequel::Constants::CONTROL_NAMES, Treequel::Constants::CONTROL_OIDS, Treequel::Constants::EXTENSION_NAMES, Treequel::Constants::EXTENSION_OIDS, Treequel::Constants::FEATURE_NAMES, Treequel::Constants::FEATURE_OIDS, Treequel::Constants::MINIMAL_OPERATIONAL_ATTRIBUTES, Treequel::Constants::SCOPE, Treequel::Constants::SCOPE_NAME
Instance Attribute Summary collapse
-
#content_sync_callback ⇒ Object
The callback to call when results change.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Override the Enumerable method to update the cookie value each time a page is fetched.
-
#initialize ⇒ Object
Add the requisite instance variables to including Branchsets.
-
#on_sync(&callback) ⇒ Object
Clone the Branchset with a persistent change callback.
Methods included from Control
Instance Attribute Details
#content_sync_callback ⇒ Object
The callback to call when results change
67 68 69 |
# File 'lib/treequel/controls/contentsync.rb', line 67 def content_sync_callback @content_sync_callback end |
Instance Method Details
#each(&block) ⇒ Object
Override the Enumerable method to update the cookie value each time a page is fetched.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/treequel/controls/contentsync.rb', line 81 def each( &block ) super do |branch| self.log.debug "Looking for the sync control in controls: %p" % [ branch.controls ] branch.controls.each do |control| self.log.debug " got a %s control: %p" % [ CONTROL_NAMES[control.oid], control.decode, ] case control.oid when CONTROL_OIDS[:sync_state] self.log.debug " got a 'state' control" block.call( branch ) when CONTROL_OIDS[:sync_done] self.log.debug " got a 'done' control" break else self.log.info " got an unexpected control (%p)" % [ control ] end end end end |
#initialize ⇒ Object
Add the requisite instance variables to including Branchsets.
53 54 55 56 57 58 59 |
# File 'lib/treequel/controls/contentsync.rb', line 53 def initialize self.log.notice "The ContentSync control doesn't work yet -- it requires support for " + "IntermediateResponses, which Ruby-LDAP doesn't do yet. " + "See http://deveiate.org/projects/Treequel/ticket/6 for updates on the " + "status of this." @content_sync_callback = nil end |
#on_sync(&callback) ⇒ Object
Clone the Branchset with a persistent change callback.
71 72 73 74 75 76 |
# File 'lib/treequel/controls/contentsync.rb', line 71 def on_sync( &callback ) newset = self.clone newset.content_sync_callback = callback return newset end |