Class: Ldumbd::TreeObject
- Inherits:
-
Object
- Object
- Ldumbd::TreeObject
- Defined in:
- lib/ldumbd/tree_object.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#children ⇒ Object
Returns the value of attribute children.
Class Method Summary collapse
Instance Method Summary collapse
- #each_child(filter = [:true], recurse = false, &block) ⇒ Object
-
#initialize(attributes = {}) ⇒ TreeObject
constructor
A new instance of TreeObject.
- #matches_filter?(filter) ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ TreeObject
Returns a new instance of TreeObject.
10 11 12 13 |
# File 'lib/ldumbd/tree_object.rb', line 10 def initialize(attributes = {}) @attributes = attributes @children = [] end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/ldumbd/tree_object.rb', line 8 def attributes @attributes end |
#children ⇒ Object
Returns the value of attribute children.
7 8 9 |
# File 'lib/ldumbd/tree_object.rb', line 7 def children @children end |
Class Method Details
.by_dn(basedn, dn) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ldumbd/tree_object.rb', line 36 def self.by_dn(basedn, dn) object = nil dn_filter, model = dn_to_filter_and_model(basedn, dn) if dn_filter query = Ldumbd::FilterConverter.filter_to_sequel(model, dn_filter) result = model.where(query).first object = result ? self.new(result) : nil end object end |
Instance Method Details
#each_child(filter = [:true], recurse = false, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ldumbd/tree_object.rb', line 20 def each_child(filter = [:true], recurse = false, &block) @children.each do |child| if child.is_a?(TreeObject) if LDAP::Server::Filter.run(filter, child.attributes) yield child.attributes end child.each_child(filter, recurse, &block) if recurse elsif child < Sequel::Model query = Ldumbd::FilterConverter.filter_to_sequel(child, filter) child.where(query).each do |r| yield r end end end end |
#matches_filter?(filter) ⇒ Boolean
15 16 17 18 |
# File 'lib/ldumbd/tree_object.rb', line 15 def matches_filter?(filter) ldap_object = TableMap.sequel_to_ldap_object(@attributes) LDAP::Server::Filter.run(filter, ldap_object) end |