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 included from HumanReadable

included

Methods included from GetTextSupport

included

Methods inherited from Entry

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

Constructor Details

#initialize(name, schema) ⇒ Attribute

Returns a new instance of Attribute.



392
393
394
# File 'lib/active_ldap/schema.rb', line 392

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

Instance Attribute Details

#super_attributeObject (readonly)

Returns the value of attribute super_attribute.



391
392
393
# File 'lib/active_ldap/schema.rb', line 391

def super_attribute
  @super_attribute
end

Instance Method Details

#binary?Boolean

binary?

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

Returns:

  • (Boolean)


417
418
419
# File 'lib/active_ldap/schema.rb', line 417

def binary?
  @binary
end

#binary_required?Boolean

binary_required?

Returns true if the value MUST be transferred in binary

Returns:

  • (Boolean)


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

def binary_required?
  @binary_required
end

#directory_operation?Boolean

directory_operation?

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

Returns:

  • (Boolean)


432
433
434
# File 'lib/active_ldap/schema.rb', line 432

def directory_operation?
  @directory_operation
end

#human_attribute_descriptionObject



471
472
473
# File 'lib/active_ldap/schema.rb', line 471

def human_attribute_description
  self.class.human_attribute_description(self)
end

#human_attribute_nameObject



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

def human_attribute_name
  self.class.human_attribute_name(self)
end

#normalize_value(value) ⇒ Object



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

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

#read_only?Boolean

read_only?

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

Returns:

  • (Boolean)


400
401
402
# File 'lib/active_ldap/schema.rb', line 400

def read_only?
  @read_only
end

#single_value?Boolean

single_value?

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

Returns:

  • (Boolean)


409
410
411
# File 'lib/active_ldap/schema.rb', line 409

def single_value?
  @single_value
end

#syntaxObject



436
437
438
# File 'lib/active_ldap/schema.rb', line 436

def syntax
  @derived_syntax
end

#syntax_descriptionObject



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

def syntax_description
  send_to_syntax(nil, :description)
end

#to_hashObject



475
476
477
478
479
480
481
482
483
484
485
# File 'lib/active_ldap/schema.rb', line 475

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

#type_cast(value) ⇒ Object



455
456
457
# File 'lib/active_ldap/schema.rb', line 455

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

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


440
441
442
# File 'lib/active_ldap/schema.rb', line 440

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

#validate(value) ⇒ Object



444
445
446
447
448
449
450
451
452
453
# File 'lib/active_ldap/schema.rb', line 444

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