class Translatable::Generators::TranslationGenerator
Public Instance Methods
create_model()
click to toggle source
# File lib/generators/translatable/translation_generator.rb, line 14 def create_model self.attributes = attrs parse_attributes! invoke "active_record:model", [class_name] + attrs + ["#{options[:origin]}_id:integer:true", "#{options[:locale]}:string"], {migration: true, timestamps: true} unless model_exists? end
inject_translatable_block()
click to toggle source
all public methods in here will be run in order
# File lib/generators/translatable/translation_generator.rb, line 21 def inject_translatable_block inject_into_class model_path, class_name, generate_translatable_block end
Protected Instance Methods
file_name()
click to toggle source
# File lib/generators/translatable/translation_generator.rb, line 40 def file_name "#{options[:prefix].downcase}_#{@file_name}" end
generate_translatable_block()
click to toggle source
# File lib/generators/translatable/translation_generator.rb, line 27 def generate_translatable_block block = <<CONTENT # This class deals purely with translations themselves. Hence, any edition of # should be avoided. # In later gem version its existance might not be necessary. CONTENT # unless attributes.empty? # block << " attr_accessible :#{attributes.map(&:name).join(", :")}\n" # end block << " #attr_protected :#{options[:origin]}_id, :#{options[:locale]}\n" block end