Class: ActiveModel::IndexedRow::Mutable
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
ActiveModel::IndexedRow
|
| Defined in: | activemodel/lib/active_model/indexed_row.rb |
Constant Summary
::ActiveModel::IndexedRow - Inherited
Class Method Summary
-
.[](hash)
Builds a
Mutablerow from a::Hash, indexed in the Hash's order. -
.new(indexes, row = nil, size: indexes.size) ⇒ Mutable
constructor
: (Hash[String, Integer] |
ExtendedIndexes, ?Array?, ?size:::Integer) -> void.
::ActiveModel::IndexedRow - Inherited
| .[], .build_indexes, | |
| .key_at? | |
| .max_slot | The largest slot in #indexes, or -1 if it is empty. |
| .new, | |
| .unset_row | A row of #size slots that are all unset, to be filled in by position. |
Instance Attribute Summary
::ActiveModel::IndexedRow - Inherited
Instance Method Summary
-
#[]=(column, value)
Columns that aren't in the indexes are added after the last index.
-
#freeze
: () -> self.
-
#initialize_copy(other)
: (Mutable) -> void.
-
#length
Alias for #size.
- #size (also: #length)
::ActiveModel::IndexedRow - Inherited
| #== | : (untyped) -> bool. |
| #[] | : (String) -> untyped. |
| #at | Like #[], but looks the value up by its slot in the row rather than by name. |
| #each_key | : () ?{ (String) -> void } -> (Array | Enumerator[String, Array[String]]). |
| #each_value | : () ?{ (untyped) -> void } -> (self | Enumerator[untyped, self]). |
| #eql?, | |
| #except | : (*String) -> Hash[String, untyped]. |
| #fetch | : (String) ?{ () -> untyped } -> untyped. |
| #fetch_at | Like #fetch, but looks the value up by its slot in the row rather than by name. |
| #hash, | |
| #key? | : (String) -> bool. |
| #key_at? | Like #key?, but looks the column up by its index in the row. |
| #keys | : () -> Array. |
| #length | Alias for #size. |
| #size | : () -> |
| #to_h | : () -> Hash[String, untyped]. |
| #to_hash | Alias for #to_h. |
| #transform_row | Like #transform_values, but returns a |
| #transform_values | : () ?{ (untyped) -> untyped } -> (Hash[String, untyped] | Enumerator[untyped, Hash[String, untyped]]). |
| #values | : () -> Array. |
| #values_at | : (*String) -> Array. |
| #index_for | The position of |
Constructor Details
.new(indexes, row = nil, size: indexes.size) ⇒ Mutable
: (Hash[String, Integer] | ExtendedIndexes, ?Array?, ?size: ::Integer) -> void
Class Method Details
.[](hash)
Builds a Mutable row from a ::Hash, indexed in the Hash's order.
: (Hash[String, untyped] | Mutable) -> Mutable
Instance Method Details
#[]=(column, value)
Columns that aren't in the indexes are added after the last index. The indexes are replaced rather than modified, since they're usually shared with other rows. : (String, untyped) -> untyped
# File 'activemodel/lib/active_model/indexed_row.rb', line 392
def []=(column, value) unless index = @indexes[column] index = [@row.size, IndexedRow.max_slot(@indexes) + 1].max @indexes = ExtendedIndexes.add(@indexes, column, index) end if index >= @row.size @row.concat(IndexedRow.unset_row(index - @row.size + 1)) end @row[index] = value end
#freeze
: () -> self
# File 'activemodel/lib/active_model/indexed_row.rb', line 378
def freeze @row.freeze super end
#initialize_copy(other)
: (Mutable) -> void
# File 'activemodel/lib/active_model/indexed_row.rb', line 372
def initialize_copy(other) super @row = @row.dup end
#length
Alias for #size.
# File 'activemodel/lib/active_model/indexed_row.rb', line 386
alias_method :length, :size
#size Also known as: #length
[ GitHub ]# File 'activemodel/lib/active_model/indexed_row.rb', line 383
def size @row.size - @row.count(UNSET) end