Sha256: 3de6494331c62b17e40c72314719eb7f9d9d49df1042f9300eb26c8014be5cda

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

module Scrivito
  module Generators
    class WidgetGenerator < ::Rails::Generators::NamedBase
      include ::Rails::Generators::Migration

      source_root File.expand_path('../templates', __FILE__)

      def self.next_migration_number(dirname)
        Scrivito::Migration.next_migration_number(current_migration_number(dirname))
      end

      def create_model
        template 'model.erb', "app/models/#{file_name}.rb"
      end

      def create_views
        template 'show.html.erb', "app/views/#{file_name}/show.html.erb"
        template 'details.html.erb', "app/views/#{file_name}/details.html.erb"
        template 'thumbnail.html.erb', "app/views/#{file_name}/thumbnail.html.erb"
      end

      def generate_migration
        migration_template 'migration.erb',
          File.join(Scrivito::Configuration.migration_path, "create_#{file_name}_migration.rb")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrivito_sdk-0.30.0 lib/generators/scrivito/widget/widget_generator.rb