Sha256: 7da9e3a94156d23a6c57de6f2b01a4ec03731c0dbeaa0238a44516b8290ab740

Contents?: true

Size: 1.17 KB

Versions: 33

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require "rails/generators/base"

module ShopifyApp
  module Generators
    class HomeControllerGenerator < Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      class_option :embedded, type: :string, default: "true"

      def create_home_controller
        template(home_controller_template, "app/controllers/home_controller.rb")
      end

      def create_products_controller
        generate("shopify_app:products_controller") if embedded? || embedded_app?
      end

      def create_home_index_view
        template("index.html.erb", "app/views/home/index.html.erb")
      end

      def add_home_index_route
        route("root :to => 'home#index'")
      end

      private

      def embedded?
        options["embedded"] == "true"
      end

      def embedded_app?
        ShopifyApp.configuration.embedded_app?
      end

      def home_controller_template
        return "unauthenticated_home_controller.rb" unless authenticated_home_controller_required?

        "home_controller.rb"
      end

      def authenticated_home_controller_required?
        !embedded? || !embedded_app?
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
shopify_app-22.4.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-22.3.1 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-22.3.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-22.2.1 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-22.2.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-22.1.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-22.0.1 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-22.00.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.10.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.9.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.8.1 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.8.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.7.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.6.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.5.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.4.1 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.4.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.3.1 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.3.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb
shopify_app-21.2.0 lib/generators/shopify_app/home_controller/home_controller_generator.rb