Class: ActiveRecord::AttributeSet::Builder
- Inherits:
-
Object
- Object
- ActiveRecord::AttributeSet::Builder
- Defined in:
- lib/active_record/attribute_set/builder.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#always_initialized ⇒ Object
readonly
Returns the value of attribute always_initialized.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
- #build_from_database(values = {}, additional_types = {}) ⇒ Object
-
#initialize(types, always_initialized = nil) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(types, always_initialized = nil) ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 |
# File 'lib/active_record/attribute_set/builder.rb', line 6 def initialize(types, always_initialized = nil) @types = types @always_initialized = always_initialized end |
Instance Attribute Details
#always_initialized ⇒ Object (readonly)
Returns the value of attribute always_initialized.
4 5 6 |
# File 'lib/active_record/attribute_set/builder.rb', line 4 def always_initialized @always_initialized end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
4 5 6 |
# File 'lib/active_record/attribute_set/builder.rb', line 4 def types @types end |
Instance Method Details
#build_from_database(values = {}, additional_types = {}) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/active_record/attribute_set/builder.rb', line 11 def build_from_database(values = {}, additional_types = {}) if always_initialized && !values.key?(always_initialized) values[always_initialized] = nil end attributes = LazyAttributeHash.new(types, values, additional_types) AttributeSet.new(attributes) end |