Sha256: 4ca78b8c9bbea92b6e5f0b1ac1158b45d8c21bd363a61b899185eedf133a363c

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

require 'model_base'

module ModelBase
  module Generators
    autoload :ModelSupport, 'model_base/generators/model_support'

    module Erb
      autoload :Scaffold, 'model_base/generators/erb/scaffold'
    end

    module FactoryBot
      autoload :Model, 'model_base/generators/factory_bot/model'
    end

    module Rails
      autoload :ScaffoldController, 'model_base/generators/rails/scaffold_controller'
    end

    class << self
      def enable!
        ::Rails::Generators::NamedBase.prepend(ModelSupport)
        templates_dir = File::expand_path('../../templates', __FILE__)
        ::Rails::Generators.templates_path.unshift(templates_dir)
        ::Rails::Generators.send(:lookup, ["rails:scaffold_controller"])
        ::Rails::Generators::ScaffoldControllerGenerator.source_paths.unshift(templates_dir)
        Erb::Scaffold.enable!
        FactoryBot::Model.enable!
        Rails::ScaffoldController.enable!
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
model_base_generators-0.4.0 lib/model_base/generators.rb