From fe5dc92f3acbe242f62af52fb9e0df3fbf38872d Mon Sep 17 00:00:00 2001 From: Hiroaki Otsu Date: Wed, 1 Apr 2020 21:00:12 +0900 Subject: [PATCH] Fix context from class to instance on which rule be applied --- lib/macrow.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/macrow.rb b/lib/macrow.rb index dd244a2..e36f1d0 100644 --- a/lib/macrow.rb +++ b/lib/macrow.rb @@ -29,7 +29,7 @@ def rule(keyword, &block) define_method "apply_rule_for_#{keyword}!" do |str, object| if str.include? replace_string(keyword) begin - str.gsub!(replace_string(keyword), block.call(object).to_s) + str.gsub!(replace_string(keyword), instance_exec(object, &block).to_s) str rescue NoMethodError => e fail Macrow::ReplaceError, "NoMethodError is raised on applying rule: '#{keyword}'. Please check your rule. Error message is '#{e.message}'"