Sha256: 4ce727b1a638e8395ba97705fe1c7f2c10ef435c3de6d71344d6f4693884d2b7

Contents?: true

Size: 620 Bytes

Versions: 7

Compression:

Stored size: 620 Bytes

Contents

module EnvironmentOverride
  module_function
  def with_anti_virus_scanner(success = true)
    if ! Rails.configuration.respond_to?(:default_antivirus_instance)
      raise RuntimeError, "Undefined Rails.configuration.default_antivirus_instance"
    end
    before_override = Rails.configuration.default_antivirus_instance

    instance = success ? lambda {|f| 0 } : lambda {|f| 1 }
    Rails.configuration.default_antivirus_instance = instance
    yield
  ensure
    if Rails.configuration.respond_to?(:default_antivirus_instance)
      Rails.configuration.default_antivirus_instance = before_override
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curate-0.3.2 spec/support/environment_override.rb
curate-0.3.1 spec/support/environment_override.rb
curate-0.2.0 spec/support/environment_override.rb
curate-0.1.3 spec/support/environment_override.rb
curate-0.1.2 spec/support/environment_override.rb
curate-0.1.1 spec/support/environment_override.rb
curate-0.1.0 spec/support/environment_override.rb