Class: FactoryBot::Generators::Base

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/factory_bot.rb

Overview

:nodoc:

Direct Known Subclasses

ModelGenerator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/factory_bot.rb', line 6

def self.source_root
  path = File.join(
    File.dirname(__FILE__),
    "factory_bot",
    generator_name,
    "templates"
  )

  File.expand_path(path)
end

Instance Method Details

#explicit_class_optionObject



21
22
23
24
25
# File 'lib/generators/factory_bot.rb', line 21

def explicit_class_option
  return if class_name.underscore == factory_name

  ", class: '#{class_name}'"
end

#factory_nameObject



17
18
19
# File 'lib/generators/factory_bot.rb', line 17

def factory_name
  class_name.gsub("::", "").underscore
end