class Para::OrderableGenerator

Public Class Methods

next_migration_number(dir) click to toggle source
# File lib/generators/para/orderable/orderable_generator.rb, line 41
def self.next_migration_number(dir)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Public Instance Methods

add_field_to_model() click to toggle source
# File lib/generators/para/orderable/orderable_generator.rb, line 15
def add_field_to_model
  migration_template(
    'orderable_migration.rb',
    "db/migrate/add_orderable_position_to_#{ table_name }.rb"
  )
end
add_orderable_to_model() click to toggle source
# File lib/generators/para/orderable/orderable_generator.rb, line 22
def add_orderable_to_model
  class_definition = /class #{ class_name } < (ActiveRecord::Base|ApplicationRecord)\n/

  inject_into_file "app/models/#{ singular_namespaced_path }.rb", after: class_definition do
    "  acts_as_orderable\n"
  end
end
fianl_message() click to toggle source
# File lib/generators/para/orderable/orderable_generator.rb, line 34
def fianl_message
  message = "The #{ class_name } model is now orderable.\n"
  message << "Please migrate to update your model's table\n" unless options[:migrate]

  say(message)
end
migrate() click to toggle source
# File lib/generators/para/orderable/orderable_generator.rb, line 30
def migrate
  rake 'db:migrate' if options[:migrate]
end
welcome() click to toggle source
# File lib/generators/para/orderable/orderable_generator.rb, line 11
def welcome
  say "Making #{ class_name } model orderable ..."
end