Class: LOM
- Inherits:
-
Object
- Object
- LOM
- Defined in:
- lib/lom/core.rb,
lib/lom/ldap.rb,
lib/lom/mapper.rb,
lib/lom/handler.rb,
lib/lom/version.rb,
lib/lom/filtered.rb
Defined Under Namespace
Modules: EntryEnhanced, LDAP, Mapper Classes: ConvertionError, EntryNotFound, Error, Filtered, MappingError
Constant Summary collapse
- TIME_FORMAT =
Time format used in ldap
"%Y%m%d%H%M%SZ"
- VERSION =
'0.9.0'
Class Method Summary collapse
-
.debug ⇒ Object
Get debugging mode.
-
.debug=(v) ⇒ Object
Set debugging mode.
-
.id_from_dn(dn, branch, attr = nil) ⇒ String?
Retrieve the identifier.
-
.lh ⇒ Object
Get the LDAP handler to use.
- .lh=(lh) ⇒ Object
-
.to_ldap_time(ts) ⇒ String
Convert a Date/Time object to an ldap string representation.
Class Method Details
.debug ⇒ Object
Get debugging mode
40 41 42 |
# File 'lib/lom/core.rb', line 40 def self.debug @@debug ||= [] end |
.debug=(v) ⇒ Object
Set debugging mode
46 47 48 |
# File 'lib/lom/core.rb', line 46 def self.debug=(v) @@debug = v end |
.id_from_dn(dn, branch, attr = nil) ⇒ String?
Retrieve the identifier.
The given ‘dn` should be a direct child of the `branch`, and if `attr` is specified, the attribute name should also match.
~~~ dn = “uid=jdoe,ou=People,dc=example,dc=com” LOM.id_from_dn(dn, “ou=People,dc=example,dc=com”, :uid) ~~~
24 25 26 27 28 29 30 31 |
# File 'lib/lom/ldap.rb', line 24 def self.id_from_dn(dn, branch, attr = nil) if sub = Net::LDAP::DN.sub?(dn, branch) k, v, o = sub.to_a if o.nil? && (!attr.nil? || (k == attr.to_s)) v end end end |
.lh ⇒ Object
Get the LDAP handler to use
In order of preference:
-
the handler set using lh=
-
the LH constant in this scope or parent scope
-
the one defined in $lh
19 20 21 |
# File 'lib/lom/handler.rb', line 19 def self.lh @lh || const_get(:LH) || $lh end |
.lh=(lh) ⇒ Object
7 8 9 |
# File 'lib/lom/handler.rb', line 7 def self.lh=(lh) @lh = lh end |
.to_ldap_time(ts) ⇒ String
Convert a Date/Time object to an ldap string representation
31 32 33 34 35 36 37 |
# File 'lib/lom/core.rb', line 31 def self.to_ldap_time(ts) case ts when Date, Time then ts.strftime(TIME_FORMAT) when nil then nil else raise ArgumentError end end |