Sha256: a0a90a49d5665c79069fd77145c2a6d71dc1353efc0ee3721bbb385131b72497
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require 'rails/generators/erb' require 'rails/generators/resource_helpers' module AwsRecord module Generators class ErbGenerator < Base include Rails::Generators::ResourceHelpers source_root File.expand_path('templates', __dir__) argument :attributes, type: :array, default: [], banner: 'field:type field:type' def initialize(args, *options) options[0] << '--skip-table-config' super end def create_root_folder empty_directory File.join('app/views', controller_file_path) end def copy_view_files available_views.each do |view| formats.each do |format| filename = filename_with_extensions(view, format) template filename, File.join('app/views', controller_file_path, filename) end end end private def available_views %w[index edit show new _form] end def formats [format] end def format :html end def handler :erb end def filename_with_extensions(name, file_format = format) [name, file_format, handler].compact.join('.') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aws-record-rails-0.2.0 | lib/generators/aws_record/erb/erb_generator.rb |
aws-record-rails-0.1.0 | lib/generators/aws_record/erb/erb_generator.rb |