Module: DynamicActiveModel

Defined in:
lib/dynamic-active-model.rb,
lib/dynamic-active-model/setup.rb,
lib/dynamic-active-model/factory.rb,
lib/dynamic-active-model/version.rb,
lib/dynamic-active-model/database.rb,
lib/dynamic-active-model/explorer.rb,
lib/dynamic-active-model/foreign_key.rb,
lib/dynamic-active-model/associations.rb,
lib/dynamic-active-model/has_many_through.rb,
lib/dynamic-active-model/template_class_file.rb,
lib/dynamic-active-model/foreign_key_constraints.rb,
lib/dynamic-active-model/dangerous_attributes_patch.rb

Overview

DynamicActiveModel is a Ruby gem that provides automatic database discovery, model creation, and relationship mapping for Rails applications.

It allows developers to dynamically create ActiveRecord models from existing database schemas without manually writing model classes. The gem automatically detects and sets up relationships including has_many, belongs_to, has_one, and has_and_belongs_to_many based on database constraints.

Examples:

Basic Usage

module DB; end
DynamicActiveModel::Explorer.explore(DB, database_config)

Model Extension

db = DynamicActiveModel::Database.new(DB, database_config)
db.update_model(:users) do
  def full_name
    "#{first_name} #{last_name}"
  end
end

Defined Under Namespace

Modules: DangerousAttributesPatch, Explorer, Setup Classes: Associations, ClassNameConflict, Database, Error, Factory, ForeignKey, ForeignKeyConstraints, HasManyThrough, ModelNotFound, TemplateClassFile

Constant Summary collapse

VERSION =

Gem version, bumped by release-please

'1.4.0'

Class Method Summary collapse

Class Method Details

.deprecator ⇒ ActiveSupport::Deprecation

Deprecation warnings for this gem; dynamic-active-model-rails registers it in Rails.application.deprecators so the app's deprecation settings apply

Returns:

  • (ActiveSupport::Deprecation)


58
59
60
61
62
63
# File 'lib/dynamic-active-model.rb', line 58

def self.deprecator
  @deprecator ||= begin
    require 'active_support/deprecation'
    ActiveSupport::Deprecation.new('1.0', 'dynamic-active-model')
  end
end