Sha256: d8fec9b7eb05862885f46665fa39bc0e30d6b40b2576d17bd44b4fb51f7a94e3

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

require "rails/generators"
require "rails/generators/active_record"

module Scenic
  module Generators
    class ViewGenerator < Rails::Generators::NamedBase
      include Rails::Generators::Migration
      source_root File.expand_path("../templates", __FILE__)

      def create_view_definition
        create_file "db/views/#{plural_name}_v1.sql"
      end

      def create_migration_file
        migration_template(
          "db/migrate/create_view.erb",
          "db/migrate/create_#{plural_name}.rb"
        )
      end

      def self.next_migration_number(dir)
        ::ActiveRecord::Generators::Base.next_migration_number(dir)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scenic-0.1.0 lib/generators/scenic/view/view_generator.rb