123456789_123456789_123456789_123456789_123456789_

Class: ActiveModel::AttributeSet::Builder::FromDBContext

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Context
Instance Chain:
self, Context
Inherits: ActiveModel::AttributeSet::Builder::Context
Defined in: activemodel/lib/active_model/attribute_set/builder.rb

Overview

For records loaded from the database, which only fall back to the defaults in #default_keys. Other attributes the row doesn't have are missing.

Class Method Summary

Context - Inherited

.new

names are the attribute names by index, type_table their TypeTable, and defaults the default attributes by index that attributes a row doesn't have fall back to.

Instance Attribute Summary

Context - Inherited

Instance Method Summary

Context - Inherited

#default_at

The default attribute for the attribute at index, if any.

#name_at

The name of the attribute at index.

#type_at

The type of the attribute at index in a row laid out with #indexes.

#type_key_at?

: (Integer) -> bool?

Constructor Details

.new(names, type_table, defaults, default_keys) ⇒ FromDBContext

: (Array, TypeTable, Array, untyped) -> void

[ GitHub ]

  
# File 'activemodel/lib/active_model/attribute_set/builder.rb', line 76

def initialize(names, type_table, defaults, default_keys)
  defaults = names.each_with_index.map do |name, index|
    defaults[index] if default_keys.include?(name)
  end
  super(names, type_table, defaults.freeze)
end