module Kiqr::Generators::OrmHelpers

Private Instance Methods

migration_exists?(table_name) click to toggle source
# File lib/generators/kiqr/orm_helpers.rb, line 12
def migration_exists?(table_name)
  Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_kiqr_to_#{table_name}.rb$/).first
end
migration_path() click to toggle source
# File lib/generators/kiqr/orm_helpers.rb, line 16
def migration_path
  if Rails.version >= '5.0.3'
    db_migrate_path
  else
    @migration_path ||= File.join('db', 'migrate')
  end
end
migration_version() click to toggle source
# File lib/generators/kiqr/orm_helpers.rb, line 28
def migration_version
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails5_and_up?
end
model_exists?() click to toggle source
# File lib/generators/kiqr/orm_helpers.rb, line 8
def model_exists?
  File.exist?(File.join(destination_root, model_path))
end
model_path() click to toggle source
# File lib/generators/kiqr/orm_helpers.rb, line 24
def model_path
  @model_path ||= File.join('app', 'models', "#{file_path}.rb")
end
rails5_and_up?() click to toggle source
# File lib/generators/kiqr/orm_helpers.rb, line 32
def rails5_and_up?
  Rails::VERSION::MAJOR >= 5
end