Class: LDAP::Mod
- Inherits:
-
Object
- Object
- LDAP::Mod
- Defined in:
- lib/ldap/mod.rb
Constant Summary collapse
- BasicAttributes =
javax.naming.directory.BasicAttributes
- BasicAttribute =
javax.naming.directory.BasicAttribute
- ModificationItem =
javax.naming.directory.ModificationItem
- DirContext =
javax.naming.directory.DirContext
Class Method Summary collapse
- .ruby_mod_to_java(mod_op) ⇒ Object
- .to_java_attributes(*attrs) ⇒ Object
- .to_java_modification_items(*attrs) ⇒ Object
Instance Method Summary collapse
-
#initialize(mod_type, attr, vals) ⇒ Mod
constructor
A new instance of Mod.
-
#mod_op ⇒ Object
should be mod_type.
-
#mod_type ⇒ Object
should be attr.
- #mod_vals ⇒ Object
- #to_java_attribute ⇒ Object
Constructor Details
#initialize(mod_type, attr, vals) ⇒ Mod
Returns a new instance of Mod.
43 44 45 |
# File 'lib/ldap/mod.rb', line 43 def initialize(mod_type, attr, vals) @type, @attr, @vals = mod_type, attr, vals end |
Class Method Details
.ruby_mod_to_java(mod_op) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/ldap/mod.rb', line 27 def ruby_mod_to_java(mod_op) case (mod_op&~LDAP::LDAP_MOD_BVALUES) when LDAP::LDAP_MOD_ADD then DirContext::ADD_ATTRIBUTE when LDAP::LDAP_MOD_REPLACE then DirContext::REPLACE_ATTRIBUTE when LDAP::LDAP_MOD_DELETE then DirContext::REMOVE_ATTRIBUTE else raise LDAP::Error, "can't handle operation #{mod_op}" end end |
.to_java_attributes(*attrs) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ldap/mod.rb', line 20 def to_java_attributes(*attrs) attrs.inject(BasicAttributes.new) do |res, attr| res.put(attr.to_java_attribute) res end end |
.to_java_modification_items(*attrs) ⇒ Object
36 37 38 39 40 |
# File 'lib/ldap/mod.rb', line 36 def to_java_modification_items(*attrs) attrs.map do |val| ModificationItem.new(ruby_mod_to_java(val.mod_op), val.to_java_attribute) end.to_java ModificationItem end |
Instance Method Details
#mod_op ⇒ Object
should be mod_type
47 48 49 |
# File 'lib/ldap/mod.rb', line 47 def mod_op #should be mod_type @type end |
#mod_type ⇒ Object
should be attr
51 52 53 |
# File 'lib/ldap/mod.rb', line 51 def mod_type #should be attr @attr end |
#mod_vals ⇒ Object
55 56 57 |
# File 'lib/ldap/mod.rb', line 55 def mod_vals @vals end |
#to_java_attribute ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ldap/mod.rb', line 59 def to_java_attribute v = BasicAttribute.new(self.mod_type) binary = mod_op & LDAP::LDAP_MOD_BVALUES if binary != 0 self.mod_vals.each do |val| v.add(val.to_java_bytes) end else self.mod_vals.each do |val| v.add(val) end end v end |