Class: Tosspayments2::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/tosspayments2/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_controllerObject



17
18
19
20
21
22
# File 'lib/generators/tosspayments2/install/install_generator.rb', line 17

def create_controller
  return unless options[:controller]

  template 'payments_controller.rb', 'app/controllers/payments_controller.rb'
  template 'payments_helper.rb', 'app/helpers/payments_helper.rb'
end

#create_css_fileObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/tosspayments2/install/install_generator.rb', line 34

def create_css_file
  return unless options[:with_model]

  # app/assets/stylesheets 디렉토리 생성
  empty_directory 'app/assets/stylesheets'

  # CSS 파일 복사
  template 'tosspayments.css', 'app/assets/stylesheets/tosspayments.css'

  # application.css에 import 추가
  add_css_import_to_application
end

#create_initializerObject



13
14
15
# File 'lib/generators/tosspayments2/install/install_generator.rb', line 13

def create_initializer
  template 'initializer.rb', 'config/initializers/tosspayments.rb'
end

#create_stimulus_controllerObject



24
25
26
27
28
29
30
31
32
# File 'lib/generators/tosspayments2/install/install_generator.rb', line 24

def create_stimulus_controller
  return unless options[:with_model]

  # app/javascript/controllers 디렉토리 생성
  empty_directory 'app/javascript/controllers'

  # Stimulus 컨트롤러 파일 복사
  template 'tosspayments_checkout_controller.js', 'app/javascript/controllers/tosspayments_checkout_controller.js'
end