Class: ActiveLdap::Adapter::JndiConnection::ModifyRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/active_ldap/adapter/jndi_connection.rb

Constant Summary collapse

DirContext =
directory.DirContext
BasicAttribute =
directory.BasicAttribute
ADD_ATTRIBUTE =
DirContext::ADD_ATTRIBUTE
REPLACE_ATTRIBUTE =
DirContext::REPLACE_ATTRIBUTE
REMOVE_ATTRIBUTE =
DirContext::REMOVE_ATTRIBUTE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, name, values, binary) ⇒ ModifyRecord

Returns a new instance of ModifyRecord.



52
53
54
55
56
57
# File 'lib/active_ldap/adapter/jndi_connection.rb', line 52

def initialize(type, name, values, binary)
  @type = self.class.const_get("#{type.to_s.upcase}_ATTRIBUTE")
  @name = name
  @values = values
  @binary = binary
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



51
52
53
# File 'lib/active_ldap/adapter/jndi_connection.rb', line 51

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



51
52
53
# File 'lib/active_ldap/adapter/jndi_connection.rb', line 51

def type
  @type
end

#valuesObject (readonly)

Returns the value of attribute values.



51
52
53
# File 'lib/active_ldap/adapter/jndi_connection.rb', line 51

def values
  @values
end

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/active_ldap/adapter/jndi_connection.rb', line 59

def binary?
  @binary
end

#to_java_attributeObject



67
68
69
70
71
72
73
74
75
# File 'lib/active_ldap/adapter/jndi_connection.rb', line 67

def to_java_attribute
  attribute = BasicAttribute.new(@name)
  values = @values
  values = values.collect(&:to_java_bytes) if binary?
  values.each do |value|
    attribute.add(value)
  end
  attribute
end

#to_java_modification_itemObject



63
64
65
# File 'lib/active_ldap/adapter/jndi_connection.rb', line 63

def to_java_modification_item
  ModificationItem.new(@type, to_java_attribute)
end