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.



281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/active_ldap/schema.rb', line 281

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.



280
281
282
# File 'lib/active_ldap/schema.rb', line 280

def length
  @length
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

#binary_transfer_required?Boolean

Returns:

  • (Boolean)


294
295
296
# File 'lib/active_ldap/schema.rb', line 294

def binary_transfer_required?
  @binary_transfer_required
end

#human_readable?Boolean

Returns:

  • (Boolean)


298
299
300
# File 'lib/active_ldap/schema.rb', line 298

def human_readable?
  @human_readable
end

#normalize_value(value) ⇒ Object



322
323
324
325
326
327
328
# File 'lib/active_ldap/schema.rb', line 322

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

#to_paramObject



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

def to_param
  id
end

#type_cast(value) ⇒ Object



314
315
316
317
318
319
320
# File 'lib/active_ldap/schema.rb', line 314

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

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


302
303
304
# File 'lib/active_ldap/schema.rb', line 302

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

#validate(value) ⇒ Object



306
307
308
309
310
311
312
# File 'lib/active_ldap/schema.rb', line 306

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