Class: ActiveLdap::Schema::Syntax

Inherits:
Entry
  • Object
show all
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

Constructor Details

#initialize(id, schema) ⇒ Syntax

Returns a new instance of Syntax.



317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/active_ldap/schema.rb', line 317

def initialize(id, schema)
  if /\{(\d+)\}\z/ =~ id
    id = $PREMATCH
    @length = Integer($1)
  else
    @length = nil
  end
  super(id, schema, "ldapSyntaxes")
  @id = id
  @name = nil if @name == @id
  @validator = Syntaxes[@id]
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



316
317
318
# File 'lib/active_ldap/schema.rb', line 316

def length
  @length
end

Instance Method Details

#<=>(other) ⇒ Object



366
367
368
# File 'lib/active_ldap/schema.rb', line 366

def <=>(other)
  id <=> other.id
end

#binary_transfer_required?Boolean

Returns:

  • (Boolean)


330
331
332
# File 'lib/active_ldap/schema.rb', line 330

def binary_transfer_required?
  @binary_transfer_required
end

#human_readable?Boolean

Returns:

  • (Boolean)


334
335
336
# File 'lib/active_ldap/schema.rb', line 334

def human_readable?
  @human_readable
end

#normalize_value(value) ⇒ Object



358
359
360
361
362
363
364
# File 'lib/active_ldap/schema.rb', line 358

def normalize_value(value)
  if @validator
    @validator.normalize_value(value)
  else
    value
  end
end

#to_paramObject



370
371
372
# File 'lib/active_ldap/schema.rb', line 370

def to_param
  id
end

#type_cast(value) ⇒ Object



350
351
352
353
354
355
356
# File 'lib/active_ldap/schema.rb', line 350

def type_cast(value)
  if @validator
    @validator.type_cast(value)
  else
    value
  end
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


338
339
340
# File 'lib/active_ldap/schema.rb', line 338

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

#validate(value) ⇒ Object



342
343
344
345
346
347
348
# File 'lib/active_ldap/schema.rb', line 342

def validate(value)
  if @validator
    @validator.validate(value)
  else
    nil
  end
end