Module: Immunio::ActiveSupportHooks

Extended by:
ActiveSupport::Concern
Defined in:
lib/immunio/plugins/action_view/active_support_hash.rb

Overview

Hook for the ‘ActiveSupport::Hash#to_query`. Use case: building a url within a decorator that renders a partial with an interpolation.

Instance Method Summary collapse

Instance Method Details

#to_query_with_immunio(namespace = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/immunio/plugins/action_view/active_support_hash.rb', line 13

def to_query_with_immunio(namespace = nil)
  escaped_string = to_query_without_immunio(namespace)
  Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do
    # Our markers got escaped, so un-unescaped them back.
    escaped_string.gsub!(
      Immunio::Template::ENCODED_IMMUNIO_TOKENS_RE,
      "{immunio-\\1:\\2:\\3}\\4{/immunio-\\1:\\2:\\3}")
  end
  escaped_string
end