Sha256: 595837db1b42dd3b653e2aecfa4f4a507942ceaf5fddce4821f0b977390a92d3

Contents?: true

Size: 472 Bytes

Versions: 1

Compression:

Stored size: 472 Bytes

Contents

module Belajar
  module Loadable

    require 'active_support/inflector'

    def load(path)
      if Dir.exist?(path)
        dirs = Dir.entries(path).select do |entry|
          !entry.match(/\./)
        end

        dirs.sort.map do |dir|
          dir_path = File.join(path, dir)
          class_name = self.to_s.demodulize.singularize
          "Belajar::#{class_name}".constantize.new(dir_path)
        end
      else
        Array.new
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belajar-0.1.1 lib/belajar/loadable.rb