Class: ROM::LDAP::Dataset Private
- Inherits:
-
Object
- Object
- ROM::LDAP::Dataset
- Extended by:
- Initializer
- Includes:
- Enumerable, ActiveSupportInstrumentation, Conversion, DSL, Persistence
- Defined in:
- lib/rom/ldap/dataset.rb,
lib/rom/ldap/dataset/dsl.rb,
lib/rom/ldap/dataset/conversion.rb,
lib/rom/ldap/dataset/persistence.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: Conversion, DSL, Persistence
Instance Attribute Summary collapse
-
#base ⇒ String
readonly
Set when initializing a relation.
-
#criteria ⇒ Array
readonly
Query AST.
- #direction ⇒ Symbol readonly
- #directory ⇒ Directory readonly
-
#name ⇒ String
readonly
Valid LDAP filter filter string.
-
#offset ⇒ Integer
readonly
Pagination per_page(20).
Class Method Summary collapse
-
.dsl ⇒ Array<Symbol>
private
Collection of Dataset::DSL module methods.
Instance Method Summary collapse
-
#bind(password) ⇒ Boolean
Validate the password against the filtered user.
-
#each(*args, &block) ⇒ Array <Directory::Entry>, Enumerator <Directory::Entry>
Iterate over the entries return from the server.
-
#export ⇒ Hash+
private
Handle different string output formats i.e.
-
#grep(attrs, value) ⇒ Relation
Wildcard search on multiple attributes.
-
#inspect ⇒ String
Inspect dataset revealing current ast and base.
-
#join(new_criteria, constructor = :con_and) ⇒ Relation
Combine AST criteria - use AND by default.
-
#map(attr = nil, &block) ⇒ Mixed
Iterate over each entry or one attribute of each entry.
-
#opts ⇒ Hash
Internal options.
-
#total ⇒ Integer
Unrestricted count of every entry under the search base with the domain entry discounted.
-
#unfiltered ⇒ Dataset
This method is present in Sequel and ensures rom-sql/rom-ldap plugin interoperability.
-
#with(overrides) ⇒ ROM::LDAP::Dataset
Initialise a new class overriding options.
Methods included from Conversion
Methods included from Persistence
Methods included from DSL
#approx, #begins, #binary_equal, #bitwise, #contains, #ends, #equal, #excludes, #gt, #gte, #inverse, #lt, #lte, #missing, #outside, #present, #unequal, #within
Methods included from ActiveSupportInstrumentation
Instance Attribute Details
#base ⇒ String (readonly)
Returns Set when initializing a relation.
35 |
# File 'lib/rom/ldap/dataset.rb', line 35 option :base, type: Types::DN, reader: :private, default: proc { directory.base } |
#criteria ⇒ Array (readonly)
Returns Query AST.
40 |
# File 'lib/rom/ldap/dataset.rb', line 40 option :criteria, type: Types::Strict::Array, reader: :private, default: proc { EMPTY_ARRAY } |
#direction ⇒ Symbol (readonly)
45 |
# File 'lib/rom/ldap/dataset.rb', line 45 option :direction, type: Types::Direction, reader: :private, default: proc { :asc } |
#name ⇒ String (readonly)
Returns Valid LDAP filter filter string.
29 |
# File 'lib/rom/ldap/dataset.rb', line 29 option :name, type: Types::Filter, reader: :private |
#offset ⇒ Integer (readonly)
Returns Pagination per_page(20).
50 |
# File 'lib/rom/ldap/dataset.rb', line 50 option :offset, type: Types::Strict::Integer, reader: :private, optional: true |
Class Method Details
.dsl ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Collection of Dataset::DSL module methods.
Used by Relation to forward methods to Dataset.
84 85 86 |
# File 'lib/rom/ldap/dataset.rb', line 84 def self.dsl DSL.public_instance_methods(false) end |
Instance Method Details
#bind(password) ⇒ Boolean
Validate the password against the filtered user.
202 203 204 |
# File 'lib/rom/ldap/dataset.rb', line 202 def bind(password) directory.bind_as(filter: to_ast, password: password) end |
#each(*args, &block) ⇒ Array <Directory::Entry>, Enumerator <Directory::Entry>
Iterate over the entries return from the server.
115 116 117 118 119 120 121 122 |
# File 'lib/rom/ldap/dataset.rb', line 115 def each(*args, &block) results = paginated? ? entries[page_range] : entries results = results.sort_by { rand } if random results = results.reverse_each if reversed? results = results.map { |e| apply_aliases(e) } if aliases.any? block_given? ? results.each(*args, &block) : results.to_enum end |
#export ⇒ Hash+
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Handle different string output formats
i.e. DSML, LDIF, JSON, YAML, MessagePack.
211 212 213 214 |
# File 'lib/rom/ldap/dataset.rb', line 211 def export results = map(&:canonical) results.one? ? results.first : results end |
#grep(attrs, value) ⇒ Relation
Wildcard search on multiple attributes.
167 168 169 170 171 172 |
# File 'lib/rom/ldap/dataset.rb', line 167 def grep(attrs, value) new_criteria = attrs.map do |attr| match_dsl([[attr, value]], left: WILDCARD, right: WILDCARD) end join(new_criteria, :con_or) end |
#inspect ⇒ String
Inspect dataset revealing current ast and base.
138 139 140 |
# File 'lib/rom/ldap/dataset.rb', line 138 def inspect %(#<#{self.class}: base="#{base}" #{to_ast} />) end |
#join(new_criteria, constructor = :con_and) ⇒ Relation
Combine AST criteria - use AND by default
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/rom/ldap/dataset.rb', line 184 def join(new_criteria, constructor = :con_and) new_chain = join_dsl(constructor, new_criteria) # check because RestrictionDSL sometimes offers empty criteria if new_chain.empty? self else chain(*new_chain) end end |
#map(attr = nil, &block) ⇒ Mixed
Iterate over each entry or one attribute of each entry.
129 130 131 |
# File 'lib/rom/ldap/dataset.rb', line 129 def map(attr = nil, &block) each.map { |entry| attr ? entry[attr] : entry }.map(&block) end |
#opts ⇒ Hash
Returns internal options.
105 106 107 |
# File 'lib/rom/ldap/dataset.rb', line 105 def opts .merge(ast: to_ast, filter: to_filter).freeze end |
#total ⇒ Integer
Unrestricted count of every entry under the search base
with the domain entry discounted.
222 223 224 |
# File 'lib/rom/ldap/dataset.rb', line 222 def total directory.base_total - 1 end |
#unfiltered ⇒ Dataset
This method is present in Sequel and ensures rom-sql/rom-ldap plugin interoperability.
147 148 149 |
# File 'lib/rom/ldap/dataset.rb', line 147 def unfiltered with(criteria: EMPTY_ARRAY) end |
#with(overrides) ⇒ ROM::LDAP::Dataset
Initialise a new class overriding options.
98 99 100 |
# File 'lib/rom/ldap/dataset.rb', line 98 def with(overrides) self.class.new(.merge(overrides)) end |