Commit d88bf787 authored by Ruben Davila's avatar Ruben Davila

Use RequestStore to cache the contents of the current License.

parent a10be3cc
......@@ -14,21 +14,27 @@ class License < ActiveRecord::Base
class << self
def current
return @current if @current
license = self.last
return unless license && license.valid?
@current = license
if RequestStore.active?
RequestStore.fetch(:current_license) { load_license }
else
load_license
end
end
def reset_current
@current = nil
RequestStore.delete(:current_license)
end
def block_changes?
!current || current.block_changes?
end
def load_license
license = self.last
return unless license && license.valid?
license
end
end
def data_filename
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment