Class: Grn::Generators::P1Generator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/grn/p1/p1_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ P1Generator

Returns a new instance of P1Generator.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/grn/p1/p1_generator.rb', line 16

def initialize(*args, &block)
  super
  
  unless options.nomes_padroes
    @recurso_nome = ask('Nome do recurso:')
    @tipo_recurso_nome = ask('Nome do tipo do recurso:')
  end
  @recurso_nome = 'Recurso' if @recurso_nome.blank?
  @tipo_recurso_nome = 'TipoRecurso' if @tipo_recurso_nome.blank?
  
end

Instance Attribute Details

#recurso_nomeObject

Returns the value of attribute recurso_nome.



12
13
14
# File 'lib/generators/grn/p1/p1_generator.rb', line 12

def recurso_nome
  @recurso_nome
end

#tipo_recurso_nomeObject

Returns the value of attribute tipo_recurso_nome.



12
13
14
# File 'lib/generators/grn/p1/p1_generator.rb', line 12

def tipo_recurso_nome
  @tipo_recurso_nome
end

Instance Method Details

#gerar_arquivosObject



28
29
30
31
# File 'lib/generators/grn/p1/p1_generator.rb', line 28

def gerar_arquivos
  template 'recurso.rb', "#{MDWA::DSL::STRUCTURAL_PATH}#{MDWA::DSL::Entity.new(@recurso_nome).file_name}.rb"
  template 'tipo_recurso.rb', "#{MDWA::DSL::STRUCTURAL_PATH}#{MDWA::DSL::Entity.new(@tipo_recurso_nome).file_name}.rb"
end