class Nexmo::Markdown::DynamicContentFilter
Public Instance Methods
call(input)
click to toggle source
# File lib/nexmo_markdown_renderer/filters/dynamic_content_filter.rb, line 4 def call(input) input.gsub(/(\s|^)\[\~(.+?)\~\](\s|$)/) do content = environment_value($2) || config_value($2) || "VALUE NOT SET: #{$2}" "#{$1}#{content}#{$3}" end end
Private Instance Methods
config_value(key)
click to toggle source
# File lib/nexmo_markdown_renderer/filters/dynamic_content_filter.rb, line 21 def config_value(key) @config_dynamic_content ||= YAML.load_file("#{GEM_ROOT}/config/dynamic_content.yml") @config_dynamic_content[key] end
environment_value(key)
click to toggle source
# File lib/nexmo_markdown_renderer/filters/dynamic_content_filter.rb, line 13 def environment_value(key) return nil unless ENV['DYNAMIC_CONTENT'] @environment_dynamic_content ||= YAML.safe_load(ENV['DYNAMIC_CONTENT']) @environment_dynamic_content ||= YAML.safe_load(temp) @environment_dynamic_content[key] end