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



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

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
  @built_in_syntax = Syntaxes[@id]
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length



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

def length
  @length
end

Instance Method Details

#<=>(other) ⇒ Object



372
373
374
# File 'lib/active_ldap/schema.rb', line 372

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

#binary?Boolean

Returns:

  • (Boolean)


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

def binary?
  return true if @built_in_syntax and @built_in_syntax.binary?
  binary_transfer_required? or !human_readable?
end

#binary_transfer_required?Boolean

Returns:

  • (Boolean)


336
337
338
# File 'lib/active_ldap/schema.rb', line 336

def binary_transfer_required?
  @binary_transfer_required
end

#human_readable?Boolean

Returns:

  • (Boolean)


340
341
342
# File 'lib/active_ldap/schema.rb', line 340

def human_readable?
  @human_readable
end

#normalize_value(value) ⇒ Object



364
365
366
367
368
369
370
# File 'lib/active_ldap/schema.rb', line 364

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

#to_paramObject



376
377
378
# File 'lib/active_ldap/schema.rb', line 376

def to_param
  id
end

#type_cast(value) ⇒ Object



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

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

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


344
345
346
# File 'lib/active_ldap/schema.rb', line 344

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

#validate(value) ⇒ Object



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

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