Sha256: 67967d0de1cdf3c0b6b0165c95c675e223274dc6e5a892a7eff22e083bb6510f

Contents?: true

Size: 919 Bytes

Versions: 21

Compression:

Stored size: 919 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

      def create_resources
        if defined?(User).present?
          Rails::Generators.invoke("avo:resource", ["user", "-q"], {destination_root: Rails.root })
        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

21 entries across 21 versions & 1 rubygems

Version Path
avo-3.9.2 lib/generators/avo/install_generator.rb
avo-3.9.1 lib/generators/avo/install_generator.rb
avo-3.8.2 lib/generators/avo/install_generator.rb
avo-3.9.0 lib/generators/avo/install_generator.rb
avo-3.8.1 lib/generators/avo/install_generator.rb
avo-3.8.0 lib/generators/avo/install_generator.rb
avo-3.6.4 lib/generators/avo/install_generator.rb
avo-3.6.3 lib/generators/avo/install_generator.rb
avo-3.6.2 lib/generators/avo/install_generator.rb
avo-3.6.1 lib/generators/avo/install_generator.rb
avo-3.6.0 lib/generators/avo/install_generator.rb
avo-3.5.8 lib/generators/avo/install_generator.rb
avo-3.5.7 lib/generators/avo/install_generator.rb
avo-3.5.6 lib/generators/avo/install_generator.rb
avo-3.5.6.beta1 lib/generators/avo/install_generator.rb
avo-3.5.5 lib/generators/avo/install_generator.rb
avo-3.5.4 lib/generators/avo/install_generator.rb
avo-3.5.3 lib/generators/avo/install_generator.rb
avo-3.5.2 lib/generators/avo/install_generator.rb
avo-3.5.1 lib/generators/avo/install_generator.rb