Sha256: b0245fc11d8c5b3cb82f6d9495aa3db9bd1c96e91c92b3227fbd84ee8107ad7f

Contents?: true

Size: 839 Bytes

Versions: 2

Compression:

Stored size: 839 Bytes

Contents

module DuckPuncher
  module Ducks
    autoload :String, 'duck_puncher/ducks/string'
    autoload :Array, 'duck_puncher/ducks/array'
    autoload :Numeric, 'duck_puncher/ducks/numeric'
    autoload :Hash, 'duck_puncher/ducks/hash'
    autoload :Object, 'duck_puncher/ducks/object'
    autoload :Method, 'duck_puncher/ducks/method'
    autoload :ActiveRecord, 'duck_puncher/ducks/active_record'
    autoload :Module, 'duck_puncher/ducks/module'

    class << self
      def list
        @list ||= DuckPuncher.ancestral_hash
      end

      def [](klass)
        list[klass]
      end

      def load_mods(klass, loaded_mods: [])
        if klass.respond_to?(:superclass)
          load_mods(klass.superclass, loaded_mods: list[klass].to_a.map(&:mod) + loaded_mods)
        else
          loaded_mods
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
duck_puncher-4.1.0 lib/duck_puncher/ducks.rb
duck_puncher-4.0.0 lib/duck_puncher/ducks.rb