def acts_as_substitutable_instance_methods(method)
class_eval("before_save :clear_substituted_params\n\ndef substituted_\#{method}\nreturn '' if self.\#{method}.blank?\nunless @sub_\#{method}\n@sub_\#{method} = self.\#{method}.dup\n\nif (subs = @sub_\#{method}.scan(substitution_\#{method}_regex)).any?\nsubs.flatten.compact.each do |sub|\nmethod = \#{method}_sub_options[sub.downcase.to_sym]\nval = if method.is_a?(Proc)\nmethod.call(self)\nelsif method\nself.send method\nend\n@sub_\#{method}.gsub!(sub_key_to_val(sub), val)\nend\nend\nend\n@sub_\#{method}\nend\n\nprotected\ndef substitution_\#{method}_regex\n@@substitution_\#{method}_regex ||=\nRegexp.new \#{method}_sub_options.keys.collect{|key|\nsub_key_to_val(key, ['\\\\$(', ')\\\\$'])\n}.join('|')\nend\n\n\ndef sub_key_to_val(key, surround = ['$', '$'])\n\nval = surround.first\nval << key.to_s.upcase\nval << surround.last\nval\nend\n\ndef \#{method}_sub_options\nself.class.acts_as_sub_options[:\#{method}]\nend\n", __FILE__, __LINE__)
end