Sha256: fa4a64c7e8dc6329d7802034c39e73182d758013e9c5302be63b25199131d5e0

Contents?: true

Size: 960 Bytes

Versions: 2

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  module Dbt
    module Generators
      class StagingModelGenerator < Rails::Generators::NamedBase
        source_root File.expand_path('templates', __dir__)

        def create_staging_model_sql_file
          template 'staging_model.sql.tt', sql.export_path
        end

        def create_staging_model_yml_file
          create_file yml.export_path, yml.yml_dump
        end

        private

        def sql
          @sql ||= ActiveRecord::Dbt::Model::Staging::Sql.new(name)
        end

        def yml
          @yml ||= ActiveRecord::Dbt::Factory::Model::StagingFactory.yml_build(name)
        end

        def source_paths
          config_directory_path = ActiveRecord::Dbt::Config.instance.config_directory_path

          [
            File.expand_path(config_directory_path, Rails.root),
            File.expand_path('./templates/', __dir__)
          ]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-dbt-0.2.0 lib/generators/active_record/dbt/staging_model/staging_model_generator.rb
activerecord-dbt-0.1.0 lib/generators/active_record/dbt/staging_model/staging_model_generator.rb