Sha256: 6ad0bec777663dc36043bad3b543ae0ca563bfe808271c0338acbeffb7c9e896

Contents?: true

Size: 668 Bytes

Versions: 3

Compression:

Stored size: 668 Bytes

Contents

# frozen_string_literal: true

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

module MooTool
  class ControllerBase
    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 ||= []
      @@controllers << child
    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

3 entries across 3 versions & 1 rubygems

Version Path
mootool-0.1.2 lib/mootool/controller_base.rb
mootool-0.1.1 lib/mootool/controller_base.rb
mootool-0.1.0 lib/mootool/controller_base.rb