class WCC::Contentful::Middleman::Extension::ContentfulSyncUpdate
Rack app that advances the sync engine whenever we load a page
Public Class Methods
last_sync()
click to toggle source
# File lib/wcc/contentful/middleman/extension.rb, line 74 def last_sync @@last_sync ||= Time.at(0) # rubocop:disable Style/ClassVars end
last_sync=(time)
click to toggle source
# File lib/wcc/contentful/middleman/extension.rb, line 78 def last_sync=(time) @@last_sync = time # rubocop:disable Style/ClassVars end
new(app)
click to toggle source
# File lib/wcc/contentful/middleman/extension.rb, line 60 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/wcc/contentful/middleman/extension.rb, line 64 def call(env) if (Time.now - ContentfulSyncUpdate.last_sync) > 10.seconds ::WCC::Contentful::Services.instance.sync_engine&.next ContentfulSyncUpdate.last_sync = Time.now end @app.call(env) end