Module: ACLSystem2::LogicParser
- Included in:
- AccessHandler
- Defined in:
- lib/acl_system2/logic_parser.rb
Instance Method Summary collapse
-
#process(logicstring, context) ⇒ Object
recursively processes an permission string and returns true or false.
Instance Method Details
#process(logicstring, context) ⇒ Object
recursively processes an permission string and returns true or false
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/acl_system2/logic_parser.rb', line 9 def process(logicstring, context) # if logicstring contains any parenthasized patterns, call process recursively on them while logicstring =~ /\(/ logicstring.sub!(/\(([^\)]+)\)/) { process($1, context) } end # process each operator in order of precedence #! while logicstring =~ /!/ logicstring.sub!(/!([^ &|]+)/) { (!check(logicstring[$1], context)).to_s } end #& if logicstring =~ /&/ return (process(logicstring[/^[^&]+/], context) and process(logicstring[/^[^&]+&(.*)$/,1], context)) end #| if logicstring =~ /\|/ return (process(logicstring[/^[^\|]+/], context) or process(logicstring[/^[^\|]+\|(.*)$/,1], context)) end # constants if logicstring =~ /^\s*true\s*$/i return true elsif logicstring =~ /^\s*false\s*$/i return false end # single list items (check(logicstring.strip, context)) end |