Class: PicoPhone::Rails::PhoneNumberGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- PicoPhone::Rails::PhoneNumberGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/pico_phone/rails/phone_number/phone_number_generator.rb
Overview
Invoked as rails generate pico_phone:rails:phone_number PhoneNumber.
For apps starting a phone-number table from scratch -- unlike
maintain_phone_search_index itself, which has no generator on
purpose, since it needs to map onto whatever columns an existing
table already has.
Generates a migration for a table with a raw number column plus all
four search-index columns (e164, national_digits, reversed_digits,
region), and a starter model with maintain_phone_search_index
already wired up.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ String
26 27 28 |
# File 'lib/generators/pico_phone/rails/phone_number/phone_number_generator.rb', line 26 def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#create_migration_file ⇒ void
This method returns an undefined value.
31 32 33 |
# File 'lib/generators/pico_phone/rails/phone_number/phone_number_generator.rb', line 31 def create_migration_file migration_template "create_table.rb.tt", "db/migrate/create_#{table_name}.rb" end |
#create_model_file ⇒ void
This method returns an undefined value.
36 37 38 |
# File 'lib/generators/pico_phone/rails/phone_number/phone_number_generator.rb', line 36 def create_model_file template "model.rb.tt", "app/models/#{file_path}.rb" end |