Class: ActiveLdap::Schema::Attribute — activeldap - ActiveLdap

Class: ActiveLdap::Schema::Attribute

Inherits:
Entry
  • Object
show all
Includes:
GetTextSupport, HumanReadable
Defined in:
lib/active_ldap/schema.rb

Instance Attribute Summary (collapse)

Attributes inherited from Entry

#aliases, #description, #id, #name

Instance Method Summary (collapse)

Methods inherited from Entry

#<=>, #eql?, #hash, #to_param

Constructor Details

- (Attribute) initialize(name, schema)

Returns a new instance of Attribute



398
399
400
# File 'lib/active_ldap/schema.rb', line 398

def initialize(name, schema)
  super(name, schema, "attributeTypes")
end

Instance Attribute Details

- (Object) super_attribute (readonly)

Returns the value of attribute super_attribute



397
398
399
# File 'lib/active_ldap/schema.rb', line 397

def super_attribute
  @super_attribute
end

Instance Method Details

- (void) apply_encoding(value)

This method returns an undefined value.

Sets binary encoding to value if the given attribute's syntax is binary syntax. Does nothing otherwise.



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/active_ldap/schema.rb', line 430

def apply_encoding(value)
  return unless binary?
  case value
  when Hash
    value.each_value do |sub_value|
      apply_encoding(sub_value)
    end
  when Array
    value.each do |sub_value|
      apply_encoding(sub_value)
    end
  else
    return unless value.respond_to?(:force_encoding)
    value.force_encoding("ASCII-8BIT")
  end
end

- (Boolean) binary?

binary?

Returns true if the given attribute's syntax is binary syntax, X-NOT-HUMAN-READABLE or X-BINARY-TRANSFER-REQUIRED

Returns:

  • (Boolean)


423
424
425
# File 'lib/active_ldap/schema.rb', line 423

def binary?
  @binary
end

- (Boolean) binary_required?

binary_required?

Returns true if the value MUST be transferred in binary

Returns:

  • (Boolean)


450
451
452
# File 'lib/active_ldap/schema.rb', line 450

def binary_required?
  @binary_required
end

- (Boolean) directory_operation?

directory_operation?

Returns true if an attribute is directory operation. It means that USAGE contains directoryOperation.

Returns:

  • (Boolean)


458
459
460
# File 'lib/active_ldap/schema.rb', line 458

def directory_operation?
  @directory_operation
end

- (Object) human_attribute_description



497
498
499
# File 'lib/active_ldap/schema.rb', line 497

def human_attribute_description
  self.class.human_attribute_description(self)
end

- (Object) human_attribute_name



493
494
495
# File 'lib/active_ldap/schema.rb', line 493

def human_attribute_name
  self.class.human_attribute_name(self)
end

- (Object) normalize_value(value)



485
486
487
# File 'lib/active_ldap/schema.rb', line 485

def normalize_value(value)
  normalize_value_internal(value, false)
end

- (Boolean) read_only?

read_only?

Returns true if an attribute is read-only NO-USER-MODIFICATION

Returns:

  • (Boolean)


406
407
408
# File 'lib/active_ldap/schema.rb', line 406

def read_only?
  @read_only
end

- (Boolean) single_value?

single_value?

Returns true if an attribute can only have one value defined SINGLE-VALUE

Returns:

  • (Boolean)


415
416
417
# File 'lib/active_ldap/schema.rb', line 415

def single_value?
  @single_value
end

- (Object) syntax



462
463
464
# File 'lib/active_ldap/schema.rb', line 462

def syntax
  @derived_syntax
end

- (Object) syntax_description



489
490
491
# File 'lib/active_ldap/schema.rb', line 489

def syntax_description
  send_to_syntax(nil, :description)
end

- (Object) to_hash



501
502
503
504
505
506
507
508
509
510
511
# File 'lib/active_ldap/schema.rb', line 501

def to_hash
  {
    :read_only => read_only?,
    :single_value => single_value?,
    :binary => binary?,
    :binary_required => binary_required?,
    :directory_operation => directory_operation?,
    :syntax => syntax,
    :syntax_description => syntax_description,
  }
end

- (Object) type_cast(value)



481
482
483
# File 'lib/active_ldap/schema.rb', line 481

def type_cast(value)
  send_to_syntax(value, :type_cast, value)
end

- (Boolean) valid?(value)

Returns:

  • (Boolean)


466
467
468
# File 'lib/active_ldap/schema.rb', line 466

def valid?(value)
  validate(value).nil?
end

- (Object) validate(value)



470
471
472
473
474
475
476
477
478
479
# File 'lib/active_ldap/schema.rb', line 470

def validate(value)
  error_info = validate_each_value(value)
  return error_info if error_info
  begin
    normalize_value(value)
    nil
  rescue AttributeValueInvalid
    [$!.message]
  end
end