Module: Decidim::DecidimAwesome::RequestMemoizer
- Included in:
- AwesomeHelpers, Proposals::MemoizeExtraFields
- Defined in:
- lib/decidim/decidim_awesome/request_memoizer.rb
Instance Method Summary collapse
-
#memoize(key) ⇒ Object
memoize a piece of code in the global request instead of the helper instance (helpers are initialized for each view).
Instance Method Details
#memoize(key) ⇒ Object
memoize a piece of code in the global request instead of the helper instance (helpers are initialized for each view)
7 8 9 10 11 12 13 |
# File 'lib/decidim/decidim_awesome/request_memoizer.rb', line 7 def memoize(key) if defined?(request) && request.env["decidim.current_organization"]&.id request.env["decidim_awesome.#{key}"] ||= block_given? ? yield : nil elsif block_given? yield end end |