class ActsAsBelongableGenerator

Public Class Methods

next_migration_number(dirname) click to toggle source
# File lib/generators/acts_as_belongable_generator.rb, line 12
def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    Time.now.utc.strftime '%Y%m%d%H%M%S'
  else
    format('%.3d', current_migration_number(dirname) + 1)
  end
end

Public Instance Methods

create_migration_file() click to toggle source
# File lib/generators/acts_as_belongable_generator.rb, line 20
def create_migration_file
  migration_template 'migration.rb.erb',
                     'db/migrate/acts_as_belongable_migration.rb',
                     migration_version: migration_version
end
create_model() click to toggle source
# File lib/generators/acts_as_belongable_generator.rb, line 26
def create_model
  template 'model.rb', 'app/models/belonging.rb'
end
show_readme() click to toggle source
# File lib/generators/acts_as_belongable_generator.rb, line 30
def show_readme
  readme 'README.md'
end

Private Instance Methods

migration_version() click to toggle source
# File lib/generators/acts_as_belongable_generator.rb, line 36
def migration_version
  return unless Rails.version >= '5.0.0'

  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end