class ActiveModel::AttributeSet
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_model/attribute_set.rbs class ActiveModel::AttributeSet def []: (String name) -> (ActiveModel::Attribute::FromDatabase | ActiveModel::Attribute::FromUser) def []=: (String name, ActiveModel::Attribute::FromDatabase value) -> untyped def fetch_value: (String name, ) -> untyped end
:nodoc:
def ==(other)
def ==(other) attributes == other.attributes end
def [](name)
Experimental RBS support (using type sampling data from the type_fusion
project).
def []: (String name) -> (ActiveModel::Attribute::FromDatabase | ActiveModel::Attribute::FromUser)
This signature was generated using 4 samples from 1 application.
def [](name) @attributes[name] || default_attribute(name) end
def []=(name, value)
Experimental RBS support (using type sampling data from the type_fusion
project).
def []=: (String name, ActiveModel::Attribute::FromDatabase value) -> untyped
This signature was generated using 2 samples from 1 application.
def []=(name, value) @attributes[name] = value end
def accessed
def accessed attributes.each_key.select { |name| self[name].has_been_read? } end
def deep_dup
def deep_dup AttributeSet.new(attributes.deep_dup) end
def default_attribute(name)
def default_attribute(name) Attribute.null(name) end
def fetch_value(name, &block)
Experimental RBS support (using type sampling data from the type_fusion
project).
def fetch_value: (String name, ) -> untyped
This signature was generated using 1 sample from 1 application.
def fetch_value(name, &block) self[name].value(&block) end
def freeze
def freeze attributes.freeze super end
def initialize(attributes)
def initialize(attributes) @attributes = attributes end
def initialize_clone(_)
def initialize_clone(_) @attributes = @attributes.clone super end
def initialize_dup(_)
def initialize_dup(_) @attributes = @attributes.dup super end
def key?(name)
def key?(name) attributes.key?(name) && self[name].initialized? end
def keys
def keys attributes.each_key.select { |name| self[name].initialized? } end
def map(&block)
def map(&block) new_attributes = attributes.transform_values(&block) AttributeSet.new(new_attributes) end
def reset(key)
def reset(key) if key?(key) write_from_database(key, nil) end end
def to_hash
def to_hash keys.index_with { |name| self[name].value } end
def values_before_type_cast
def values_before_type_cast attributes.transform_values(&:value_before_type_cast) end
def values_for_database
def values_for_database attributes.transform_values(&:value_for_database) end
def write_cast_value(name, value)
def write_cast_value(name, value) @attributes[name] = self[name].with_cast_value(value) end
def write_from_database(name, value)
def write_from_database(name, value) @attributes[name] = self[name].with_value_from_database(value) end
def write_from_user(name, value)
def write_from_user(name, value) raise FrozenError, "can't modify frozen attributes" if frozen? @attributes[name] = self[name].with_value_from_user(value) value end