Class: FactoryBotGenerator::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_bot_generator.rb

Constant Summary collapse

QUOTE_AROUND_VALUE_TYPES =
i[string date datetime text].freeze
EXCLUDE_COLUMNS =
%w[created_at updated_at].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, options) ⇒ Base



16
17
18
19
# File 'lib/factory_bot_generator.rb', line 16

def initialize(record, options)
  @record = record
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/factory_bot_generator.rb', line 14

def options
  @options
end

#recordObject (readonly)

Returns the value of attribute record.



14
15
16
# File 'lib/factory_bot_generator.rb', line 14

def record
  @record
end

Class Method Details

.render(record, options = {}) ⇒ Object



10
11
12
# File 'lib/factory_bot_generator.rb', line 10

def self.render(record, options = {})
  new(record, options).render
end

Instance Method Details

#renderObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/factory_bot_generator.rb', line 21

def render
  ActionView::Base.new(File.dirname(__FILE__)).render(
    file: 'factory_bot_generator.erb',
    locals: {
      name:    name,
      columns: columns,
      record:  record,
      indent:  indent
    }
  )
end