Sha256: c6b7fa6bdb4a9fc828d87bcf4fac6e6c7654f46c641bae7772170f6d376c4589

Contents?: true

Size: 390 Bytes

Versions: 1

Compression:

Stored size: 390 Bytes

Contents

require "class_lister/version"

module ClassLister
  class << self
    def list(mod, filter = true)
      return [] unless mod.respond_to?(:constants)

      mod.constants.inject([]) do |collection, name|
        const = mod.const_get name
        collection << const
        collection += list const, false
      end.tap { |c| c.select! { |c| c.is_a? Class } if filter }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
class_lister-1.0.0 lib/class_lister.rb