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.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#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, &default) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(types, always_initialized = nil, &default) ⇒ Builder
Returns a new instance of Builder.
8 9 10 11 12 |
# File 'lib/active_record/attribute_set/builder.rb', line 8 def initialize(types, always_initialized = nil, &default) @types = types @always_initialized = always_initialized @default = default end |
Instance Attribute Details
#always_initialized ⇒ Object (readonly)
Returns the value of attribute always_initialized.
6 7 8 |
# File 'lib/active_record/attribute_set/builder.rb', line 6 def always_initialized @always_initialized end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
6 7 8 |
# File 'lib/active_record/attribute_set/builder.rb', line 6 def default @default end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
6 7 8 |
# File 'lib/active_record/attribute_set/builder.rb', line 6 def types @types end |
Instance Method Details
#build_from_database(values = {}, additional_types = {}) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/active_record/attribute_set/builder.rb', line 14 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, &default) AttributeSet.new(attributes) end |