Class: Evnt::CommandGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Evnt::CommandGenerator
- Defined in:
- lib/generators/evnt/command_generator.rb
Overview
CommandGenerator.
Instance Method Summary collapse
Instance Method Details
#command_path ⇒ Object
29 30 31 32 33 34 |
# File 'lib/generators/evnt/command_generator.rb', line 29 def command_path path = './app/commands' @command_modules.map { |m| path = "#{path}/#{m.underscore}" } path = "#{path}/#{@command_class.underscore}.rb" path end |
#create_comand ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/generators/evnt/command_generator.rb', line 14 def create_comand path = informations.first.split('::') @command_class = path.last.camelize @command_modules = path - [path.last] @command_params = (informations - [informations.first]).map do |data| data = data.split(':') data.length > 1 ? ":#{data.first}, type: :#{data.last}" : ":#{data.first}" end template( './command/command.rb.erb', command_path ) end |