Sha256: 108e490a8ef83f98e4dd101da14c7df405f39aa7992fe1921d7ac784ed25f7b6

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

DuckPuncher.logger = Logger.new(STDOUT).tap do |config|
  config.formatter = proc { |*args| "[DuckPuncher] #{args[0]}: #{args[-1]}\n" }
  config.level = Logger::ERROR
end

# [Target, Extensions]
ducks = [
  [String, DuckPuncher::Ducks::String],
  [Enumerable, DuckPuncher::Ducks::Enumerable, {
    after: proc { |target|
      # Re-include Enumerable in these classes to pick up the new extensions
      hosts = [Array, Set, Range, Enumerator]
      hosts = [target] if hosts.include?(target)
      hosts.each do |k|
        DuckPuncher.logger.debug("Sending include to #{k} with Enumerable") and k.send(:include, Enumerable)
      end
    }
  }],
  [Numeric, DuckPuncher::Ducks::Numeric],
  [Hash, DuckPuncher::Ducks::Hash],
  [Object, DuckPuncher::Ducks::Object],
  [Module, DuckPuncher::Ducks::Module],
  [Method, DuckPuncher::Ducks::Method, { before: ->(_target) { DuckPuncher::GemInstaller.initialize! } }],
]
ducks << [ActiveRecord::Base, DuckPuncher::Ducks::ActiveRecord] if defined?(Rails) && defined?(ActiveRecord) && defined?(ActiveRecord::Base)
ducks.each do |duck|
  DuckPuncher.register(*duck)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duck_puncher-5.0.1 lib/duck_puncher/defaults.rb