Module: RoCommands::Generators::RailsGenerator::ClassMethods

Includes:
BaseGenerator::ClassMethods
Defined in:
lib/ro_commands/generators/rails_generator.rb

Instance Attribute Summary collapse

Attributes included from BaseGenerator::ClassMethods

#file

Instance Method Summary collapse

Methods included from BaseGenerator::ClassMethods

#create, #created_file, #ctn, #file_name, #file_write, #lastest_file, #lib_path, #open, #path, #reset, #to

Instance Attribute Details

#tofileObject

Returns the value of attribute tofile.



29
30
31
# File 'lib/ro_commands/generators/rails_generator.rb', line 29

def tofile
  @tofile
end

Instance Method Details

#templateObject



15
16
17
18
19
20
21
22
23
# File 'lib/ro_commands/generators/rails_generator.rb', line 15

def template
  template_path = File.expand_path "../rails_templates/#{template_name}.erb"

  if File.exist?(template_path)
    ctn = RoFile.read(File.expand_path("../rails_templates/#{template_name}.erb", __FILE__))
    result = ::ERB.new(ctn).result(name.send(:binding))
    RoFile.write(tofile, result)
  end
end

#template_nameObject



25
26
27
# File 'lib/ro_commands/generators/rails_generator.rb', line 25

def template_name
  name.split("::").last.uncamelize
end