Sha256: 425dd2739cf0bab730eb01ec4d2d4349460ed8274b5a96eeccc056d8153995da

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 Bytes

Contents

# typed: true
# frozen_string_literal: true

CONTROLLERS_PATH = File.join(File.dirname(__FILE__), 'controllers')

module MooTool
  # Controller base is the base class for all controllers that respond to command line requests.
  class ControllerBase
    @controllers = []

    def self.load_all
      Dir.glob(File.join(CONTROLLERS_PATH, '*')).each do |file|
        require file
      end
    end

    def self.for_controller(name)
      @@controllers.find { |c| c.command == name }
    end

    def self.inherited(child)
      @@controllers << child
      super
    end

    class << self
      def command(command = nil)
        @command = command if command
        @command
      end

      def description(description)
        @description = description
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mootool-0.2.8 lib/mootool/controller_base.rb