Sha256: 9060d307cc4ca55d9788fdbf6b35625fc12ff834cba214b3b122ff6b80cbe91d

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

class Mona::Loaders::Base
  include Mona::Mixins

  class << self
    def registry
      @registry ||= {}
    end

    def inherited(subclass)
      name = subclass.to_s.split("::").last.downcase.to_sym

      registry[name] = subclass
    end
  end

  attr_reader :overwriters, :inflections, :ignore_dirs, :autoload_dirs, :loader, :root_path

  def initialize(root_path, &block)
    @root_path = root_path
    @overwriters = []
    @inflections = {}
    @ignore_dirs = []
    @autoload_dirs = []

    instance_exec(&block) if block_given?
  end

  def push_dir(dir)
    @autoload_dirs.push(dir)
  end

  def setup
    raise StandardError.new('not implemented')
  end

  def reload
    raise StandardError.new('not implemented')
  end

  def eager_load
    raise StandardError.new('not implemented')
  end

  def check_classes
    raise StandardError.new('not implemented')
  end

  module SetupDsl
    def inflect(hash)
      @inflections.merge!(hash)
    end

    def overwrite(proc)
      overwriters.push(proc)
    end

    def ignore(glob)
      @ignore_dirs.push(glob)
    end
  end

  include SetupDsl
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mona-0.2.3 lib/mona/loaders/base.rb
mona-0.2.2 lib/mona/loaders/base.rb