Sha256: 76850197d8bc139a0294b5706b373e88abec2cffa5374daf9eac45642f8fcf5a

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 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
        copy_file 'session_storage.rb', 'app/models/session_storage.rb'
      end

      def create_session_storage_initializer
        copy_file 'shopify_session_repository.rb', 'config/initializers/shopify_session_repository.rb', force: true
      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

13 entries across 13 versions & 1 rubygems

Version Path
shopify_app-6.2.1 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.2.0 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.1.3 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.1.2 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.1.1 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.1.0 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.0.6 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.0.5 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.0.4 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.0.3 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.0.2 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.0.1 lib/generators/shopify_app/shop_model/shop_model_generator.rb
shopify_app-6.0.0 lib/generators/shopify_app/shop_model/shop_model_generator.rb