Sha256: 831e0d5885ba958aeae3ba2846d6ba795ece528982122d1eca5dad6e70264fbc

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/active_record'

module Monarchy
  class ResourceGenerator < Rails::Generators::NamedBase
    include Rails::Generators::Migration

    desc 'This generator creates a resourcify model'
    source_root File.expand_path('../templates', __dir__)

    def create_resource_file
      template 'models/resource.rb', "app/models/#{file_name}.rb"
      migration_template 'migrations/resource.rb', "db/migrate/create_#{file_name}_resource.rb"
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
monarchy-2.7.0 lib/generators/monarchy/resource_generator.rb
monarchy-2.6.1 lib/generators/monarchy/resource_generator.rb
monarchy-2.6.0 lib/generators/monarchy/resource_generator.rb
monarchy-2.5.0 lib/generators/monarchy/resource_generator.rb