Module: ActiveRecord::Embedded

Extended by:
ActiveSupport::Concern, ActiveSupport::Configurable::ClassMethods
Defined in:
lib/active_record/embedded.rb,
lib/active_record/embedded/error.rb,
lib/active_record/embedded/field.rb,
lib/active_record/embedded/index.rb,
lib/active_record/embedded/model.rb,
lib/active_record/embedded/query.rb,
lib/active_record/embedded/engine.rb,
lib/active_record/embedded/version.rb,
lib/active_record/embedded/relation.rb,
lib/active_record/embedded/interface.rb,
lib/active_record/embedded/field/hash.rb,
lib/active_record/embedded/field/time.rb,
lib/active_record/embedded/type_error.rb,
lib/active_record/embedded/aggregation.rb,
lib/active_record/embedded/association.rb,
lib/active_record/embedded/field/array.rb,
lib/active_record/embedded/field/float.rb,
lib/active_record/embedded/field/regexp.rb,
lib/active_record/embedded/field/string.rb,
lib/active_record/embedded/field/symbol.rb,
lib/active_record/embedded/model/fields.rb,
lib/active_record/embedded/field/boolean.rb,
lib/active_record/embedded/field/integer.rb,
lib/active_record/embedded/model/storage.rb,
lib/active_record/embedded/model/indexing.rb,
lib/active_record/embedded/model/querying.rb,
lib/active_record/embedded/association/one.rb,
lib/active_record/embedded/association/many.rb,
lib/active_record/embedded/index/collection.rb,
lib/active_record/embedded/model/attributes.rb,
lib/active_record/embedded/aggregation/mysql.rb,
lib/active_record/embedded/model/persistence.rb,
lib/active_record/embedded/aggregation/native.rb,
lib/active_record/embedded/association/parent.rb,
lib/active_record/embedded/dynamic_attributes.rb,
lib/active_record/embedded/aggregation/postgresql.rb,
lib/active_record/embedded/field/not_defined_error.rb,
lib/active_record/embedded/query/no_solutions_error.rb

Overview

A library for storing schema-less data in a relational database, using ActiveRecord models and corresponding to a SQL-like API. Mixing in this module to your model will allow data to be stored as serialized hashes in your SQL tables, while being rendered as models in the application just like the rest of your data.

This also serves as the root module for the rest of the library. For more information on how this library works, see the other classes in this documentation.

Defined Under Namespace

Modules: DynamicAttributes, Interface, Model, Query Classes: Aggregation, Association, Engine, Error, Field, Index, Relation, TypeError

Constant Summary collapse

VERSION =
'0.1.0.pre'
RAILS_VERSION =
'~> 6.0.0'

Class Method Summary collapse

Class Method Details

.adapterObject



85
86
87
# File 'lib/active_record/embedded.rb', line 85

def self.adapter
  Aggregation.find(config.adapter)
end

.configObject



71
72
73
74
75
76
77
# File 'lib/active_record/embedded.rb', line 71

def self.config
  @config ||= ActiveSupport::Configurable::Configuration.new.tap do |cfg|
    cfg.scan_tables = true
    cfg.adapter = :native
    cfg.serialize_data = false
  end
end

.initialize!(adapter) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/active_record/embedded.rb', line 89

def self.initialize!(adapter)
  if supports? adapter
    config.adapter = adapter.to_sym
  else
    config.serialize_data = true
  end
end

.supports?(adapter) ⇒ Boolean

Returns:



79
80
81
82
83
# File 'lib/active_record/embedded.rb', line 79

def self.supports?(adapter)
  Aggregation.find(adapter.to_sym) && true
rescue TypeError
  false
end