class Kilt::Generators::ObjectGenerator
Public Instance Methods
generate()
click to toggle source
# File lib/generators/kilt/object_generator.rb, line 11 def generate if !Kilt.config.objects || !Kilt.config.objects[self.object_name.singularize.underscore] # Build the object entry lines = [] lines << "\n\s\s#{self.object_name.singularize.underscore}:" lines << "\n\s\s\s\sfields:" self.fields.each do |field| field = field.gsub(':',': ') lines << "\n\s\s\s\s\s\s#{field.downcase}" end # Write the object entry to the kilt config append_to_file Rails.root.join('config', 'kilt', 'config.yml'), lines.join('') else puts "The #{self.object_name} object already exists" end end