Sha256: adfb4c2533ec859998f60bf8e6d2c0783565888b795e5e479c4ab1b37dd07953

Contents?: true

Size: 849 Bytes

Versions: 13

Compression:

Stored size: 849 Bytes

Contents

module DuckPuncher
  module Ducks
    autoload :String, 'duck_puncher/ducks/string'
    autoload :Enumerable, 'duck_puncher/ducks/enumerable'
    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

13 entries across 13 versions & 1 rubygems

Version Path
duck_puncher-5.0.1 lib/duck_puncher/ducks.rb
duck_puncher-5.0.0 lib/duck_puncher/ducks.rb
duck_puncher-4.5.1 lib/duck_puncher/ducks.rb
duck_puncher-4.5.0 lib/duck_puncher/ducks.rb
duck_puncher-4.4.2 lib/duck_puncher/ducks.rb
duck_puncher-4.4.1 lib/duck_puncher/ducks.rb
duck_puncher-4.4.0 lib/duck_puncher/ducks.rb
duck_puncher-4.3.1 lib/duck_puncher/ducks.rb
duck_puncher-4.3.0 lib/duck_puncher/ducks.rb
duck_puncher-4.2.3 lib/duck_puncher/ducks.rb
duck_puncher-4.2.2 lib/duck_puncher/ducks.rb
duck_puncher-4.2.1 lib/duck_puncher/ducks.rb
duck_puncher-4.2.0 lib/duck_puncher/ducks.rb