class ROM::LDAP::Parsers::AbstractSyntax
Parses and AST into and Expression/RFC filter
@api private
Public Instance Methods
call()
click to toggle source
# File lib/rom/ldap/parsers/abstract_syntax.rb, line 20 def call case ast.size # Join or negate expression when 2 constructor, part = ast expressions = if constructor.eql?(:con_not) [express(part)] else part.map(&method(:express)) end Expression.new(op: constructor, exps: expressions) # Create expression when 3 operator, attribute, value = ast Expression.new( op: operator, field: decode_attribute(attribute), value: decode_value(value) ) end end
Private Instance Methods
decode_attribute(name)
click to toggle source
# File lib/rom/ldap/parsers/abstract_syntax.rb, line 57 def decode_attribute(name) attr = attributes.find { |a| a[:name].eql?(name) } attr ? attr[:canonical] : name end
decode_constructor(sym)
click to toggle source
@param sym [Symbol] encoded version
@return [Symbol,String]
# File lib/rom/ldap/parsers/abstract_syntax.rb, line 76 def decode_constructor(sym) CONSTRUCTORS.fetch(sym, :unknown_constructor) end
decode_operator(sym)
click to toggle source
@param sym [Symbol] encoded version
@return [Symbol,String]
# File lib/rom/ldap/parsers/abstract_syntax.rb, line 84 def decode_operator(sym) OPERATORS.fetch(sym, :'???') end
decode_value(sym)
click to toggle source
Check VALUES_MAP for encoded values otherwise return input.
@param sym [Symbol,String] possible special value
@return [String] “*”, “TRUE”, “FALSE”
# File lib/rom/ldap/parsers/abstract_syntax.rb, line 68 def decode_value(sym) VALUES_MAP.fetch(sym, sym) end
express(ast_part)
click to toggle source
Express a nested AST
@api private
# File lib/rom/ldap/parsers/abstract_syntax.rb, line 53 def express(ast_part) self.class.new(ast_part, attributes).call end