Sha256: 40ea4a5fb80ed34941c985b2e6d6224c5435cd6c1fffdf966cc24992089ec47f

Contents?: true

Size: 972 Bytes

Versions: 11

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: true

require "rails/generators/base"

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

      def generate_app_extension
        template("marketing_activities_controller.rb", "app/controllers/marketing_activities_controller.rb")
        generate_routes
      end

      private

      def generate_routes
        inject_into_file(
          "config/routes.rb",
          optimize_indentation(routes, 2),
          after: "root :to => 'home#index'\n"
        )
      end

      def routes
        <<~EOS

          resource :marketing_activities, only: [:create, :update] do
            patch :resume
            patch :pause
            patch :delete
            post :republish
            post :preload_form_data
            post :preview
            post :errors
          end
        EOS
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify_app-21.0.0 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-20.2.0 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-20.1.1 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-20.1.0 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-20.0.2 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-20.0.1 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-20.0.0 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-19.1.0 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-19.0.2 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-19.0.1 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
shopify_app-19.0.0 lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb