Class: ROM::LDAP::Attribute

Inherits:
Attribute
  • Object
show all
Extended by:
Dry::Core::Cache
Defined in:
lib/rom/ldap/attribute.rb

Overview

Extended schema attributes tailored for LDAP directories

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](*args) ⇒ ROM::LDAP::Attribute

Parameters:

  • args (Mixed)

Returns:



20
21
22
# File 'lib/rom/ldap/attribute.rb', line 20

def self.[](*args)
  fetch_or_store(args) { new(*args) }
end

Instance Method Details

#!@Array

Examples:

users.where { !given_name }

Returns:

  • (Array)


184
185
186
# File 'lib/rom/ldap/attribute.rb', line 184

def !@
  [:con_not, exists]
end

#bitwise(value) ⇒ Array Also known as: ===

Parameters:

  • value (Mixed)

Returns:

  • (Array)


318
319
320
# File 'lib/rom/ldap/attribute.rb', line 318

def bitwise(value)
  [:op_eql, name, value]
end

#canonicalLDAP::Attribute

Return a new attribute in its canonical form

Returns:

See Also:



158
159
160
161
162
163
164
# File 'lib/rom/ldap/attribute.rb', line 158

def canonical
  if aliased?
    meta(alias: nil)
  else
    self
  end
end

#definitionString

Raw LDAP Attribute Definition.

Returns:

  • (String)


102
103
104
# File 'lib/rom/ldap/attribute.rb', line 102

def definition
  meta[:definition]
end

#descriptionString

OID description

Returns:

  • (String)


120
121
122
# File 'lib/rom/ldap/attribute.rb', line 120

def description
  meta[:description]
end

#editable?Boolean

Attribute definition identifies this is not a directory internal attribute and values can be altered.

Returns:

  • (Boolean)


30
31
32
# File 'lib/rom/ldap/attribute.rb', line 30

def editable?
  meta[:editable].equal?(true)
end

#existsArray Also known as: ~@

Examples:

users.where { given_name.exists }
users.where { ~given_name }

Returns:

  • (Array)


173
174
175
# File 'lib/rom/ldap/attribute.rb', line 173

def exists
  [:op_eql, name, :wildcard]
end

#extensible(value) ⇒ Array

Parameters:

  • value (Mixed)

Returns:

  • (Array)

See Also:



309
310
311
# File 'lib/rom/ldap/attribute.rb', line 309

def extensible(value)
  [:op_ext, name, value]
end

#foreign_keyLDAP::Attribute

Return a new attribute marked as a FK

Returns:



84
85
86
# File 'lib/rom/ldap/attribute.rb', line 84

def foreign_key
  meta(foreign_key: true)
end

#gt(value) ⇒ Array Also known as: >

Examples:

users.where { uid_number.gt(101) }
users.where { uid_number > 101 }

Parameters:

  • value (Mixed)

Returns:

  • (Array)


227
228
229
# File 'lib/rom/ldap/attribute.rb', line 227

def gt(value)
  [:con_not, lte(value)]
end

#gte(value) ⇒ Array Also known as: >=

Examples:

users.where { uid_number.gte(101) }
users.where { uid_number >= 101 }

Parameters:

  • value (Mixed)

Returns:

  • (Array)


255
256
257
# File 'lib/rom/ldap/attribute.rb', line 255

def gte(value)
  [:op_gte, name, value]
end

#indexedLDAP::Attribute

Returns a new attribute marked as indexed

Returns:



147
148
149
# File 'lib/rom/ldap/attribute.rb', line 147

def indexed
  meta(index: true)
end

#indexed?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/rom/ldap/attribute.rb', line 138

def indexed?
  meta[:index].equal?(true)
end

#is(value) ⇒ Array Also known as: ==

Examples:

users.where { id.is(1) }
users.where { id == 1 }

users.where(users[:id].is(1))

Parameters:

  • value (Mixed)

Returns:

  • (Array)


199
200
201
# File 'lib/rom/ldap/attribute.rb', line 199

def is(value)
  [:op_eql, name, value]
end

#joinedLDAP::Attribute

Return a new attribute marked as joined

Whenever you join two schemas, the right schema’s attribute will be marked as joined using this method

Returns:



60
61
62
# File 'lib/rom/ldap/attribute.rb', line 60

def joined
  meta(joined: true)
end

#joined?Boolean

Return if an attribute was used in a join

Examples:

schema = users.schema.join(tasks.schema)

schema[:id, :tasks].joined?
# => true

Returns:

  • (Boolean)


75
76
77
# File 'lib/rom/ldap/attribute.rb', line 75

def joined?
  meta[:joined].equal?(true)
end

#like(value) ⇒ Array Also known as: =~

Examples:

users.where { given_name.like('peter') }
users.where { given_name =~ 'peter' }

Parameters:

  • value (Mixed)

Returns:

  • (Array)


283
284
285
# File 'lib/rom/ldap/attribute.rb', line 283

def like(value)
  [:op_prx, name, value]
end

#lt(value) ⇒ Array Also known as: <

Examples:

users.where { uid_number.lt(101) }
users.where { uid_number < 101 }

Parameters:

  • value (Mixed)

Returns:

  • (Array)


241
242
243
# File 'lib/rom/ldap/attribute.rb', line 241

def lt(value)
  [:con_not, gte(value)]
end

#lte(value) ⇒ Array Also known as: <=

Examples:

users.where { uid_number.lte(101) }
users.where { uid_number <= 101 }

Parameters:

  • value (Mixed)

Returns:

  • (Array)


269
270
271
# File 'lib/rom/ldap/attribute.rb', line 269

def lte(value)
  [:op_lte, name, value]
end

#multiple?Boolean

OID permits multiple values?

Returns:

  • (Boolean)


48
49
50
# File 'lib/rom/ldap/attribute.rb', line 48

def multiple?
  meta[:single].equal?(false)
end

#not(value) ⇒ Array Also known as: !=

Examples:

users.where { id.not(1) }
users.where { id != 1 }

Parameters:

  • value (Mixed)

Returns:

  • (Array)


213
214
215
# File 'lib/rom/ldap/attribute.rb', line 213

def not(value)
  [:con_not, is(value)]
end

#not_like(value) ⇒ Array Also known as: !~

Examples:

users.where { given_name.not_like('peter') }
users.where { given_name !~ 'peter' }

Parameters:

  • value (Mixed)

Returns:

  • (Array)


297
298
299
# File 'lib/rom/ldap/attribute.rb', line 297

def not_like(value)
  [:con_not, like(value)]
end

#oidString

Attribute Numeric Object Identifier

Returns:

  • (String)


93
94
95
# File 'lib/rom/ldap/attribute.rb', line 93

def oid
  meta[:oid]
end

#single?Boolean

Attribute definition identifies this attribute can not have multiple values.

Returns:

  • (Boolean)


39
40
41
# File 'lib/rom/ldap/attribute.rb', line 39

def single?
  meta[:single].equal?(true)
end

#syntaxString

Attribute’s syntax Numeric Object Identifier

Returns:

  • (String)


111
112
113
# File 'lib/rom/ldap/attribute.rb', line 111

def syntax
  meta[:syntax]
end

#to_sString Also known as: original_name

Convert to string for ldap query using original name The canonical attribute name defined in RFC4512.

Returns:

  • (String)


130
131
132
# File 'lib/rom/ldap/attribute.rb', line 130

def to_s
  meta[:canonical] || name.to_s
end