Sha256: 0ab27fd71cb298980182a0519077ca48a0780972f79f71dd060ea24caa1d9da0
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
require 'generators/rom' module ROM module Generators class FormGenerator < Base class_option :command, banner: "--command=command", desc: "specify command to use" def create_base_form template "base_form.rb.erb", File.join("app", "forms", "#{file_name.singularize}_form.rb") end def create_new create(:new) if create_new_form? end def create_edit create(:edit) if create_edit_form? end private def create(type) template "#{type}_form.rb.erb", File.join("app", "forms", "#{type}_#{file_name.singularize}_form.rb") end def create_new_form? options[:command].blank? || %w(new create).include?(options[:command].to_s.downcase) end def create_edit_form? options[:command].blank? || %w(edit update).include?(options[:command].to_s.downcase) end def model_name class_name.singularize.camelcase end def relation class_name.pluralize.underscore end end end end
Version data entries
4 entries across 4 versions & 1 rubygems