class Fabrication::Generators::ModelGenerator
Public Class Methods
source_root()
click to toggle source
# File lib/rails/generators/fabrication/model/model_generator.rb, line 21 def self.source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates')) end
Public Instance Methods
create_fabrication_file()
click to toggle source
# File lib/rails/generators/fabrication/model/model_generator.rb, line 11 def create_fabrication_file copy_attributes_from_model if attributes.empty? template_file = File.join( options[:dir], class_path, "#{file_name}_fabricator.#{options[:extension]}" ) template 'fabricator.erb', template_file end
Private Instance Methods
copy_attributes_from_model()
click to toggle source
# File lib/rails/generators/fabrication/model/model_generator.rb, line 27 def copy_attributes_from_model model = class_name.constantize if defined?(ActiveRecord) && model < ActiveRecord::Base self.attributes = model.columns_hash.map do |name, column| Rails::Generators::GeneratedAttribute.new(name, column.type) end end rescue StandardError # no table? no problem! rescue LoadError # cannot find model file. This means it was already destroyed, so just continue. end