Class: PgAssistant::Generators::FunctionGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- PgAssistant::Generators::FunctionGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/pg_assistant/function/function_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_function_definition ⇒ Object
- #create_functions_directory ⇒ Object
- #create_migration_file ⇒ Object
Class Method Details
.next_migration_number(dir) ⇒ Object
39 40 41 |
# File 'lib/generators/pg_assistant/function/function_generator.rb', line 39 def self.next_migration_number(dir) ::ActiveRecord::Generators::Base.next_migration_number(dir) end |
Instance Method Details
#create_function_definition ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/generators/pg_assistant/function/function_generator.rb', line 17 def create_function_definition if creating_new_function? create_file definition.path else copy_file previous_definition.full_path, definition.full_path end end |
#create_functions_directory ⇒ Object
11 12 13 14 15 |
# File 'lib/generators/pg_assistant/function/function_generator.rb', line 11 def create_functions_directory unless functions_directory_path.exist? empty_directory functions_directory_path end end |
#create_migration_file ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/pg_assistant/function/function_generator.rb', line 25 def create_migration_file if creating_new_function? || migration_template( "db/migrate/create_function.erb", "db/migrate/create_#{function_name}.rb" ) else migration_template( "db/migrate/update_function.erb", "db/migrate/update_#{function_name}_to_version_#{version}.rb" ) end end |