Sha256: e9035771873f6e3fbddd78c2c756791f2959b2d355688961ffd9e324010dbdab

Contents?: true

Size: 957 Bytes

Versions: 35

Compression:

Stored size: 957 Bytes

Contents

require_relative "base_generator"

module Generators
  module Avo
    class InstallGenerator < BaseGenerator
      source_root File.expand_path("templates", __dir__)

      namespace "avo:install"
      desc "Creates an Avo initializer adds the route to the routes file."
      class_option :path, type: :string, default: "avo"

      def create_initializer_file
        route "mount Avo::Engine, at: Avo.configuration.root_path"

        template "initializer/avo.tt", "config/initializers/avo.rb"

        create_resources
      end

      no_tasks do
        def create_resources
          if defined?(User).present?
            Rails::Generators.invoke("avo:resource", ["user", "-q"], {destination_root: Rails.root})
          end
        end

        if defined?(Account) && Account.is_a?(ActiveRecord::Base)
          Rails::Generators.invoke("avo:resource", ["account", "-q"], {destination_root: Rails.root })
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
avo-3.14.3 lib/generators/avo/install_generator.rb
avo-3.14.2 lib/generators/avo/install_generator.rb
avo-3.14.1 lib/generators/avo/install_generator.rb
avo-3.14.0 lib/generators/avo/install_generator.rb
avo-3.13.7 lib/generators/avo/install_generator.rb
avo-3.13.6 lib/generators/avo/install_generator.rb
avo-3.13.5 lib/generators/avo/install_generator.rb
avo-3.13.4 lib/generators/avo/install_generator.rb
avo-3.13.3 lib/generators/avo/install_generator.rb
avo-3.13.2 lib/generators/avo/install_generator.rb
avo-3.13.1 lib/generators/avo/install_generator.rb
avo-3.13.0 lib/generators/avo/install_generator.rb
avo-3.12.0 lib/generators/avo/install_generator.rb
avo-3.11.10 lib/generators/avo/install_generator.rb
avo-3.11.9 lib/generators/avo/install_generator.rb
avo-3.11.8 lib/generators/avo/install_generator.rb
avo-3.11.7 lib/generators/avo/install_generator.rb
avo-3.11.6 lib/generators/avo/install_generator.rb
avo-3.11.5 lib/generators/avo/install_generator.rb
avo-3.11.4 lib/generators/avo/install_generator.rb