Class: TochkaCyclopsApi::Generators::ModelsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/tochka_cyclops_api/generators/models_generator.rb

Overview

Class for core generators

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(_path) ⇒ Object



38
39
40
41
# File 'lib/tochka_cyclops_api/generators/models_generator.rb', line 38

def self.next_migration_number(_path)
  sleep(1)
  Time.now.utc.strftime('%Y%m%d%H%M%S')
end

Instance Method Details

#create_migration_fileObject



29
30
31
32
33
34
35
36
# File 'lib/tochka_cyclops_api/generators/models_generator.rb', line 29

def create_migration_file
  migration_template 'tochka_cyclops_errors_migration_template.rb',
                     'db/migrate/create_tochka_cyclops_errors.rb'
  migration_template 'tochka_cyclops_requests_migration_template.rb',
                     'db/migrate/create_tochka_cyclops_requests.rb'
  migration_template 'tochka_cyclops_responses_migration_template.rb',
                     'db/migrate/create_tochka_cyclops_responses.rb'
end

#create_model_fileObject



21
22
23
24
25
26
27
# File 'lib/tochka_cyclops_api/generators/models_generator.rb', line 21

def create_model_file
  require 'active_record'

  template 'tochka_cyclops_error_model_template.rb', 'app/models/tochka_cyclops_error.rb'
  template 'tochka_cyclops_request_model_template.rb', 'app/models/tochka_cyclops_request.rb'
  template 'tochka_cyclops_response_model_template.rb', 'app/models/tochka_cyclops_response.rb'
end