Sha256: 5606abb37a50595675cec120a51608fcf9a4f40cc18f0a261a7c871318d6f4c7

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

module Pakyow
  class Application
    module Behavior
      module Assets
        # Silences asset requests from being logged.
        #
        module Silencing
          extend Support::Extension

          apply_extension do
            on "load" do
              if config.assets.silent
                # silence asset requests
                Pakyow.silence do |connection|
                  # TODO: do we need the second check?
                  connection.path.start_with?(config.assets.prefix) || self.class.asset.instances.any? { |asset|
                    asset.logical_path == connection.path
                  }
                end

                # silence requests to public files
                Pakyow.silence do |connection|
                  # TODO: really need an in-memory directory for these files
                  File.file?(File.join(config.assets.public_path, connection.path))
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pakyow-assets-1.0.6 lib/pakyow/application/behavior/assets/silencing.rb
pakyow-assets-1.0.5 lib/pakyow/application/behavior/assets/silencing.rb
pakyow-assets-1.0.4 lib/pakyow/application/behavior/assets/silencing.rb
pakyow-assets-1.0.3 lib/pakyow/application/behavior/assets/silencing.rb
pakyow-assets-1.0.2 lib/pakyow/application/behavior/assets/silencing.rb
pakyow-assets-1.0.1 lib/pakyow/application/behavior/assets/silencing.rb
pakyow-assets-1.0.0 lib/pakyow/application/behavior/assets/silencing.rb