lib/lookbook/services/data/resolvers/data_resolver.rb in lookbook-1.5.5 vs lib/lookbook/services/data/resolvers/data_resolver.rb in lookbook-2.0.0.beta.0
- old
+ new
@@ -3,14 +3,13 @@
MATCHER = /(?!.*)/
MATCH_INDEX = 1
attr_reader :eval_context, :base_dir, :file, :fallback
- def initialize(input, eval_context: nil, permit_eval: false, fail_silently: false, base_dir: Rails.root, file: nil, fallback: nil)
+ def initialize(input, eval_context: nil, fail_silently: false, base_dir: Rails.root, file: nil, fallback: nil)
@input = input.to_s
@eval_context = eval_context
- @permit_eval = permit_eval
@fail_silently = fail_silently
@fallback = fallback
@base_dir = base_dir.to_s
@file = file.to_s
end
@@ -42,11 +41,13 @@
end
def evaluate(input, fallback = @fallback)
if evaluatable?
begin
- eval_context.instance_eval(input.to_s)
+ proc {
+ eval_context.instance_eval(input.to_s)
+ }.call
rescue => exception
raise_error "Could not evaluate statetment (#{exception.message})", exception
end
else
Lookbook.logger.debug "Data cannot be evaluated (Input: '#{input}')"
@@ -59,12 +60,9 @@
end
private
def evaluatable?
- if !@permit_eval
- raise_error "Runtime evaluation is not permitted"
- end
eval_context.present?
end
end
end