Sha256: 3f96939eb9fa85b105251f2d01a08a7c009b6b7a8f3672830579a154ef7eeb74

Contents?: true

Size: 1.08 KB

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
duck_puncher-5.0.0 lib/duck_puncher/defaults.rb
duck_puncher-4.5.1 lib/duck_puncher/defaults.rb
duck_puncher-4.5.0 lib/duck_puncher/defaults.rb
duck_puncher-4.4.2 lib/duck_puncher/defaults.rb