Module: LOM::Mapper::InstanceMethods
- Defined in:
- lib/lom/mapper.rb
Instance Method Summary collapse
-
#lh ⇒ Object
LDAP handler.
-
#save! ⇒ true, false
Save object to ldap.
Instance Method Details
#lh ⇒ Object
LDAP handler
29 30 31 |
# File 'lib/lom/mapper.rb', line 29 def lh self.class.lh end |
#save! ⇒ true, false
Save object to ldap.
If object already exists, it will be updated otherwise created.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/lom/mapper.rb', line 39 def save! attrs = instance_exec(self, &self.class._ldap_to) .transform_values {|v| # Don't use Array(), not what you think on # some classes such as Time v = [ ] if v.nil? v = [ v ] unless v.is_a?(Array) v.to_ldap } id, _ = Array(attrs[self.class._ldap_prefix]) raise MappingError, 'prefix for dn has multiple values' if _ dn = self.class.ldap_dn_from_id(id) lh.update(dn: dn, attributes: attrs).then {|res| break res unless res.nil? attrs.reject! {|k, v| Array(v).empty? } lh.add(dn: dn, attributes: attrs) } end |