Module: LegacyBrokerHelper

Instance Method Summary collapse

Instance Method Details

#get_cached(key, opts = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/legacy_broker_helper.rb', line 2

def get_cached(key, opts={})
  unless Rails.configuration.action_controller.perform_caching
    if block_given?
      return yield
    end
  end

  val = Rails.cache.read(key)
  unless val
    if block_given?
      val = yield
      if val
        Rails.cache.write(key, val, opts)
      end
    end
  end

  return val
end