Sha256: a418ca41e97046c1f034c56e0892ab87a033a95e23e7f04eb01eef7a5e2f719b

Contents?: true

Size: 925 Bytes

Versions: 27

Compression:

Stored size: 925 Bytes

Contents

class Card
  module Machine
    REFRESHED="MACHINE_ASSETS_REFRESHED".freeze

    class << self
      def refresh_script_and_style
        return unless refresh_script_and_style?
        Card.fetch(:all, :script)&.update_if_source_file_changed
        Card.fetch(:all, :style)&.update_if_source_file_changed
      end

      private

      def refresh_script_and_style?
        case Cardio.config.machine_refresh
        when :eager    then true
        when :cautious then cautious_refresh?
        when :never    then false
        else
          raise Card::Error,
                "unknown option for machine_refresh: #{Cardio.config.machine_refresh}"
        end
      end

      # only refresh when cache was cleared
      def cautious_refresh?
        return false unless Card::Cache.persistent_cache
        return false if Card.cache.read REFRESHED
        Card.cache.write REFRESHED, true
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
card-1.100.0 mod/machines/lib/card/machine.rb
card-1.99.6 mod/machines/lib/card/machine.rb
card-1.99.5 mod/machines/lib/card/machine.rb
card-1.99.4 mod/machines/lib/card/machine.rb
card-1.99.3 mod/machines/lib/card/machine.rb
card-1.99.2 mod/machines/lib/card/machine.rb
card-1.99.1 mod/machines/lib/card/machine.rb
card-1.99.0 mod/machines/lib/card/machine.rb
card-1.98.3 mod/machines/lib/card/machine.rb
card-1.98.2 mod/machines/lib/card/machine.rb
card-1.98.1 mod/machines/lib/card/machine.rb
card-1.98.0 mod/machines/lib/card/machine.rb
card-1.97.0.1 mod/machines/lib/card/machine.rb
card-1.97.0 mod/machines/lib/card/machine.rb
card-1.96.8 mod/machines/lib/card/machine.rb
card-1.96.7 mod/machines/lib/card/machine.rb
card-1.96.6 mod/machines/lib/card/machine.rb
card-1.96.5 mod/machines/lib/card/machine.rb
card-1.96.4 mod/machines/lib/card/machine.rb
card-1.96.3 mod/machines/lib/card/machine.rb