Class: ActiveRecord::ModelSchema::SchemaContext::Attributes
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | activerecord/lib/active_record/model_schema/schema_context.rb |
Overview
Attributes owns a model's attribute-derived state: attribute
defaults, attribute types, and column defaults.
Class Method Summary
-
.new(context, defaults) ⇒ Attributes
constructor
Built up front, since shareable instances are frozen along with their context.
Instance Attribute Summary
Instance Method Summary
-
#column_defaults
Lazy otherwise, since evaluating them calls proc defaults.
Constructor Details
.new(context, defaults) ⇒ Attributes
Built up front, since shareable instances are frozen along with their context.
# File 'activerecord/lib/active_record/model_schema/schema_context.rb', line 32
def initialize(context, defaults) @context = context @defaults = defaults @types = defaults.cast_types.tap do |hash| hash.default = ActiveModel::Type.default_value end default_keys = DatabaseDefaultKeys.new(context.model_class.primary_key_definition, context.columns_hash) @builder = ActiveModel::AttributeSet::Builder.new(@types, defaults, default_keys) @column_defaults = defaults.to_hash.freeze if defaults.read_only? end
Instance Attribute Details
#builder (readonly)
[ GitHub ]#context (readonly)
[ GitHub ]#defaults (readonly)
[ GitHub ]#types (readonly)
[ GitHub ]Instance Method Details
#column_defaults
Lazy otherwise, since evaluating them calls proc defaults.