lib/bearcat/client.rb in bearcat-1.5.36 vs lib/bearcat/client.rb in bearcat-1.5.37

- old
+ new

@@ -37,9 +37,22 @@ super connection.builder.insert(Footrest::RaiseFootrestErrors, ExtendedRaiseFootrestErrors) connection.builder.delete(Footrest::RaiseFootrestErrors) end + def self.cache_on_self(key, &block) + @cache ||= {} + if Rails.env.development? || Rails.env.test? + block.call + else + @cache[key] ||= block.call + end + end + + def cache_on_class(key, &block) + self.class.cache_on_self(key, &block) + end + protected def rate_limited_request return yield unless rate_limiter