Sha256: d100ebc824050e00be36e4e3cc50d746f4026915f8184ffa8676b21ae3faefe8
Contents?: true
Size: 956 Bytes
Versions: 4
Compression:
Stored size: 956 Bytes
Contents
require 'generators/faat' require 'rails/generators/base' module Faat module Generators class FormsGenerator < Base argument :form_name, type: :string, default: 'app', banner: 'form_name' argument :attr, type: :array, default: [], banner: 'form attributes' def create_form @form_attributes = [] unless attr.size.zero? attr.each do |arg| if arg.include?(':') @form_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':')) else @form_attributes << Rails::Generators::GeneratedAttribute.new(arg) end end end template "form_template.rb", "app/forms/#{file_name}_form.rb" end private def attributes @form_attributes end def file_name form_name.underscore end def class_name form_name.downcase.capitalize end end end end
Version data entries
4 entries across 4 versions & 1 rubygems