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 ...@@ -14,21 +14,27 @@ class License < ActiveRecord::Base
class << self class << self
def current def current
return @current if @current if RequestStore.active?
RequestStore.fetch(:current_license) { load_license }
license = self.last else
return unless license && license.valid? load_license
end
@current = license
end end
def reset_current def reset_current
@current = nil RequestStore.delete(:current_license)
end end
def block_changes? def block_changes?
!current || current.block_changes? !current || current.block_changes?
end end
def load_license
license = self.last
return unless license && license.valid?
license
end
end end
def data_filename 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