Sha256: 64544ae53aeac62540461fac8f26a597c8b1afc50f9a5cceaa88c7f3311038d9
Contents?: true
Size: 842 Bytes
Versions: 60
Compression:
Stored size: 842 Bytes
Contents
# frozen_string_literal: true module Motor module Configs module SyncFromFile FILE_PATH = Motor::Configs::FILE_PATH MUTEXT = Mutex.new FILE_TIMESTAMPS_STORE = ActiveSupport::Cache::MemoryStore.new(size: 1.megabyte) module_function def call(with_exception: false) MUTEXT.synchronize do file = Rails.root.join(FILE_PATH) file_timestamp = begin file.ctime rescue Errno::ENOENT raise if with_exception nil end next unless file_timestamp FILE_TIMESTAMPS_STORE.fetch(file_timestamp.to_s) do Motor::Configs::SyncFromHash.call( YAML.safe_load(file.read, permitted_classes: [Time, Date]) ) end end end end end end
Version data entries
60 entries across 60 versions & 1 rubygems