Class: Enuminator::EnumGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/enuminator/enum/enum_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, *_options) ⇒ EnumGenerator

Returns a new instance of EnumGenerator.



11
12
13
14
15
16
17
18
# File 'lib/generators/enuminator/enum/enum_generator.rb', line 11

def initialize(args, *_options)
  super

  @class_name = args.shift.camelize
  @file_name = class_name.underscore.downcase
  @values = args
  @locale = options[:lang]
end

Instance Method Details

#create_enumObject



21
22
23
# File 'lib/generators/enuminator/enum/enum_generator.rb', line 21

def create_enum
  template('enumeration.rb', File.join("app/enumerations/#{file_name}.rb"))
end

#create_localeObject



26
27
28
# File 'lib/generators/enuminator/enum/enum_generator.rb', line 26

def create_locale
  template 'enumeration.yml', File.join("config/locales/#{locale}/enumerations/#{file_name}.yml")
end