class ROM::LDAP::Parsers::FilterSyntax
Parses a filter into an AST
@api private
Attributes
result[RW]
Public Instance Methods
call()
click to toggle source
# File lib/rom/ldap/parsers/filter_syntax.rb, line 22 def call if open_statement if joined_statement join_type = encode_constructor branches = [] while (branch = call) branches << branch end self.result = [join_type, branches] elsif negated_statement negator = encode_constructor self.result = [negator, call] else skip_whitespace scan_attribute attribute = encode_attribute skip_whitespace scan_operator op = encode_operator skip_whitespace scan_value value = encode_value self.result = [op, attribute, value] end close_statement result end end
Private Instance Methods
close_statement()
click to toggle source
# File lib/rom/ldap/parsers/filter_syntax.rb, line 73 def close_statement scanner.scan(/\s*\)\s*/) end
encode_attribute()
click to toggle source
@return [String,Symbol] formatted
# File lib/rom/ldap/parsers/filter_syntax.rb, line 107 def encode_attribute attr = attributes.find { |a| a[:canonical].eql?(scanner.matched) } attr ? attr[:name] : scanner.matched end
encode_constructor()
click to toggle source
@return [Symbol]
# File lib/rom/ldap/parsers/filter_syntax.rb, line 120 def encode_constructor CONSTRUCTORS.invert[scanner.matched] end
encode_operator()
click to toggle source
@return [Symbol]
# File lib/rom/ldap/parsers/filter_syntax.rb, line 126 def encode_operator OPERATORS.invert[scanner.matched] end
encode_value()
click to toggle source
@return [Mixed]
# File lib/rom/ldap/parsers/filter_syntax.rb, line 114 def encode_value Functions[:identify_value].call(scanner.matched) end
joined_statement()
click to toggle source
@return [String, NilClass] “&” or “|”
# File lib/rom/ldap/parsers/filter_syntax.rb, line 89 def joined_statement scanner.scan(CONSTRUCTOR_REGEX) end
negated_statement()
click to toggle source
@return [String, NilClass] “!”
# File lib/rom/ldap/parsers/filter_syntax.rb, line 83 def negated_statement scanner.scan(/\s*\!\s*/) end
open_statement()
click to toggle source
# File lib/rom/ldap/parsers/filter_syntax.rb, line 77 def open_statement scanner.scan(/\s*\(\s*/) end
scan_attribute()
click to toggle source
# File lib/rom/ldap/parsers/filter_syntax.rb, line 101 def scan_attribute scanner.scan(/[-\w:.]*[\w]/) end
scan_operator()
click to toggle source
# File lib/rom/ldap/parsers/filter_syntax.rb, line 97 def scan_operator scanner.scan(OPERATOR_REGEX) end
scan_value()
click to toggle source
# File lib/rom/ldap/parsers/filter_syntax.rb, line 93 def scan_value scanner.scan(VAL_REGEX) end
scanner()
click to toggle source
@return [StringScanner]
# File lib/rom/ldap/parsers/filter_syntax.rb, line 65 def scanner @scanner ||= StringScanner.new(filter) end
skip_whitespace()
click to toggle source
# File lib/rom/ldap/parsers/filter_syntax.rb, line 69 def skip_whitespace scanner.scan(/\s*/) end