Sha256: 8e981eb356f5658a54db811c2271fd9bf88501bc83037b4f3cc6e2a5daaaaead

Contents?: true

Size: 779 Bytes

Versions: 4

Compression:

Stored size: 779 Bytes

Contents

module DuckPuncher
  module Ducks
    class << self
      def list
        @list ||= [
          Duck.new(:String),
          Duck.new(:Array),
          Duck.new(:Numeric),
          Duck.new(:Hash),
          Duck.new(:Object),
          Duck.new(:Method, before: ->(*) { DuckPuncher::GemInstaller.initialize! }),
          Duck.new(:ActiveRecord, class: 'ActiveRecord::Base', if: -> { defined? ::ActiveRecord })
        ]
      end

      def [](name)
        list.find { |duck| duck.name == name.to_sym } ||
          DuckPuncher.log.info(%Q(Couldn't find "#{name}" in my list of Ducks! I know about: #{list.map(&:name).map(&:to_s)}))
      end
    end

    #
    # Autoload our ducks
    #

    list.each do |duck|
      autoload duck.name, duck.load_path
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
duck_puncher-2.9.3 lib/duck_puncher/ducks.rb
duck_puncher-2.9.2 lib/duck_puncher/ducks.rb
duck_puncher-2.9.1 lib/duck_puncher/ducks.rb
duck_puncher-2.9.0 lib/duck_puncher/ducks.rb