class Snapshotable::Generators::CreateGenerator

Public Instance Methods

active_record_class() click to toggle source
# File lib/generators/snapshotable/create_generator.rb, line 38
def active_record_class
  ActiveRecord::VERSION::MAJOR >= 5 ? 'ApplicationRecord' : 'ActiveRecord::Base'
end
generate_migration_and_model() click to toggle source
# File lib/generators/snapshotable/create_generator.rb, line 19
def generate_migration_and_model
  migration_template 'migration.rb', "db/migrate/create_#{snapshotable_model}_snapshots.rb", migration_version: migration_version
  template 'model.rb', "app/models/#{model_underscored}_snapshot.rb"
end
migration_version() click to toggle source
# File lib/generators/snapshotable/create_generator.rb, line 34
def migration_version
  "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" if ActiveRecord::VERSION::MAJOR >= 5
end
model_camelcased() click to toggle source
# File lib/generators/snapshotable/create_generator.rb, line 54
def model_camelcased
  snapshotable_model.camelcase
end
model_underscored() click to toggle source
# File lib/generators/snapshotable/create_generator.rb, line 50
def model_underscored
  snapshotable_model.underscore
end
relations_has_many() click to toggle source
# File lib/generators/snapshotable/create_generator.rb, line 46
def relations_has_many
  options['has_many']
end
relations_has_one() click to toggle source
# File lib/generators/snapshotable/create_generator.rb, line 42
def relations_has_one
  options['has_one']
end