Sha256: 94f99e54f76ac697e5e3f58f5b0d76faae2a1f03ef2a8d8556f099fb853e198c

Contents?: true

Size: 1.11 KB

Versions: 23

Compression:

Stored size: 1.11 KB

Contents

require 'rails/generators/base'
require 'rails/generators/active_record'

module ShopifyApp
  module Generators
    class ShopModelGenerator < Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../templates', __FILE__)

      def create_shop_model
        copy_file 'shop.rb', 'app/models/shop.rb'
      end

      def create_shop_migration
        copy_migration 'create_shops.rb'
      end

      def create_session_storage_initializer
        copy_file 'shopify_session_repository.rb', 'config/initializers/shopify_session_repository.rb', force: true
      end

      def create_shop_fixtures
        copy_file 'shops.yml', 'test/fixtures/shops.yml'
      end

      private

      def copy_migration(migration_name, config = {})
        migration_template(
          "db/migrate/#{migration_name}",
          "db/migrate/#{migration_name}",
          config
        )
      end

      # for generating a timestamp when using `create_migration`
      def self.next_migration_number(dir)
        ActiveRecord::Generators::Base.next_migration_number(dir)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
shopify_app-7.2.9 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.2.8 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.2.7 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.2.6 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.2.5 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.2.3 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.2.0 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.1.1 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.1.0 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.11 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.10 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.9 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.8 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.7 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.6 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.4 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.2 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.1 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-7.0.0 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.4.2 lib/generators/shopify_app/shop_model/shop_model_generator.rb