Class: Alf::Lang::Parser::Safer

Inherits:
Object
  • Object
show all
Includes:
Alf::Lang::Parser
Defined in:
lib/alf/lang/parser/safer.rb

Defined Under Namespace

Classes: Policy

Instance Method Summary collapse

Constructor Details

#initialize(helpers = [], connection = nil) ⇒ Safer

Returns a new instance of Safer.



8
9
10
# File 'lib/alf/lang/parser/safer.rb', line 8

def initialize(helpers = [], connection = nil)
  @lispy = Lispy.new(helpers, connection)
end

Instance Method Details

#parse(expr = nil, *rest, &bl) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/alf/lang/parser/safer.rb', line 12

def parse(expr = nil, *rest, &bl)
  if expr.nil? and bl
    raise SecurityError, "Parsing of ruby blocks forbidden"
  end
  return expr if expr.is_a?(Algebra::Operand)
  check_safety!(expr.to_s)
  @lispy.parse(expr.to_s, *rest, &bl)
end