class ActiveModel::LazyAttributeSet
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/active_model/attribute_set/builder.rbs class ActiveModel::LazyAttributeSet < ActiveModel::AttributeSet type ActiveModel__LazyAttributeSet_default_attribute_value = nil | Integer | String | false | Time def default_attribute: (String name, ?bool value_present, ?ActiveModel__LazyAttributeSet_default_attribute_value value) -> (ActiveModel::Attribute::FromDatabase | ActiveModel::Attribute::WithCastValue) type ActiveModel__LazyAttributeSet_fetch_value_return_value = String | Integer | nil | Date | true def fetch_value: (String name, ) -> ActiveModel__LazyAttributeSet_fetch_value_return_value def initialize: (Hash values, Hash types, Hash additional_types, Hash default_attributes, ?Hash attributes, Hash attributes) -> void def key?: (String name) -> bool end
:nodoc:
def attributes
def attributes unless @materialized values.each_key { |key| self[key] } types.each_key { |key| self[key] } @materialized = true end @attributes end
def default_attribute(
Experimental RBS support (using type sampling data from the type_fusion
project).
type ActiveModel__LazyAttributeSet_default_attribute_value = nil | Integer | String | false | Time def default_attribute: (String name, ?bool value_present, ?ActiveModel__LazyAttributeSet_default_attribute_value value) -> (ActiveModel::Attribute::FromDatabase | ActiveModel::Attribute::WithCastValue)
This signature was generated using 16 samples from 1 application.
def default_attribute( name, value_present = true, value = values.fetch(name) { value_present = false } ) type = additional_types.fetch(name, types[name]) if value_present @attributes[name] = Attribute.from_database(name, value, type, @casted_values[name]) elsif types.key?(name) if attr = default_attributes[name] @attributes[name] = attr.dup else @attributes[name] = Attribute.uninitialized(name, type) end else Attribute.null(name) end end
def fetch_value(name, &block)
Experimental RBS support (using type sampling data from the type_fusion
project).
type ActiveModel__LazyAttributeSet_fetch_value_return_value = String | Integer | nil | Date | true def fetch_value: (String name, ) -> ActiveModel__LazyAttributeSet_fetch_value_return_value
This signature was generated using 325 samples from 2 applications.
def fetch_value(name, &block) if attr = @attributes[name] return attr.value(&block) end @casted_values.fetch(name) do value_present = true value = values.fetch(name) { value_present = false } if value_present type = additional_types.fetch(name, types[name]) @casted_values[name] = type.deserialize(value) else attr = default_attribute(name, value_present, value) attr.value(&block) end end end
def initialize(values, types, additional_types, default_attributes, attributes = {})
Experimental RBS support (using type sampling data from the type_fusion
project).
type ActiveModel__LazyAttributeSet_initialize_values = id | Integer | gem_name | String | gem_version | String | receiver | String | method_name | String | location | String | type_fusion_version | String | application_name | String | source_ip | String | parameters | String | created_at | Time | updated_at | Time | return_value | String | id | Integer | user_id | Integer | choice_id | Integer | id | Integer | gem_name | String | gem_version | String | receiver | String | method_name | String | location | String | type_fusion_version | String | application_name | String | source_ip | String | parameters | String | created_at | Time | updated_at | Time | return_value | NilClass | id | Integer | zip_code | String | longitude | Float | latitude | Float | state | String | city | NilClass | street | NilClass | raw_input | NilClass | msa_id | NilClass | csa_id | NilClass | metropolitan_division_id | NilClass | id | Integer | choice | String | number | Integer | id | Integer | company_name | String | job_title | String | start_date | String | end_date | NilClass | user_id | Integer | description | String | location | String | id | Integer | company_name | String | job_title | String | start_date | String | end_date | String | user_id | Integer | description | String | location | String type ActiveModel__LazyAttributeSet_initialize_types = id | ActiveModel::Type::Integer | gem_name | ActiveModel::Type::String | gem_version | ActiveModel::Type::String | receiver | ActiveModel::Type::String | method_name | ActiveModel::Type::String | location | ActiveModel::Type::String | type_fusion_version | ActiveModel::Type::String | application_name | ActiveModel::Type::String | source_ip | ActiveModel::Type::String | parameters | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Jsonb | created_at | ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter | updated_at | ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter | return_value | ActiveModel::Type::String | id | ActiveModel::Type::Integer | user_id | ActiveModel::Type::Integer | choice_id | ActiveModel::Type::Integer | id | ActiveModel::Type::Integer | zip_code | ActiveModel::Type::String | longitude | ActiveModel::Type::Float | latitude | ActiveModel::Type::Float | state | ActiveModel::Type::String | city | ActiveModel::Type::String | street | ActiveModel::Type::String | raw_input | ActiveModel::Type::String | msa_id | ActiveModel::Type::Integer | csa_id | ActiveModel::Type::Integer | metropolitan_division_id | ActiveModel::Type::Integer | id | ActiveModel::Type::Integer | choice | ActiveModel::Type::String | number | ActiveModel::Type::Integer | id | ActiveModel::Type::Integer | company_name | ActiveModel::Type::String | job_title | ActiveModel::Type::String | start_date | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Date | end_date | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Date | user_id | ActiveModel::Type::Integer | description | ActiveModel::Type::String | location | ActiveModel::Type::String type ActiveModel__LazyAttributeSet_initialize_additional_types = 0 | ActiveModel::Type::Integer | 1 | ActiveModel::Type::String | 2 | ActiveModel::Type::String | 3 | ActiveModel::Type::String | 4 | ActiveModel::Type::String | 5 | ActiveModel::Type::String | 6 | ActiveModel::Type::String | 7 | ActiveModel::Type::String | 8 | ActiveModel::Type::String | 9 | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Jsonb | 10 | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Timestamp | 11 | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Timestamp | 12 | ActiveModel::Type::String | 0 | ActiveModel::Type::Integer | 1 | ActiveModel::Type::Integer | 2 | ActiveModel::Type::Integer | 0 | ActiveModel::Type::Integer | 1 | ActiveModel::Type::String | 2 | ActiveModel::Type::Float | 3 | ActiveModel::Type::Float | 4 | ActiveModel::Type::String | 5 | ActiveModel::Type::String | 6 | ActiveModel::Type::String | 7 | ActiveModel::Type::String | 8 | ActiveModel::Type::Integer | 9 | ActiveModel::Type::Integer | 10 | ActiveModel::Type::Integer | 0 | ActiveModel::Type::Integer | 1 | ActiveModel::Type::String | 2 | ActiveModel::Type::Integer | 0 | ActiveModel::Type::Integer | 1 | ActiveModel::Type::String | 2 | ActiveModel::Type::String | 3 | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Date | 4 | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Date | 5 | ActiveModel::Type::Integer | 6 | ActiveModel::Type::String | 7 | ActiveModel::Type::String def initialize: (ActiveModel__LazyAttributeSet_initialize_values values, ActiveModel__LazyAttributeSet_initialize_types types, ActiveModel__LazyAttributeSet_initialize_additional_types additional_types, id | ActiveModel::Attribute::FromDatabase default_attributes, ? attributes, attributes) -> void
This signature was generated using 22 samples from 2 applications.
def initialize(values, types, additional_types, default_attributes, attributes = {}) super(attributes) @values = values @types = types @additional_types = additional_types @default_attributes = default_attributes @casted_values = {} @materialized = false end
def key?(name)
Experimental RBS support (using type sampling data from the type_fusion
project).
def key?: (String name) -> bool
This signature was generated using 13 samples from 1 application.
def key?(name) (values.key?(name) || types.key?(name) || @attributes.key?(name)) && self[name].initialized? end
def keys
def keys keys = values.keys | types.keys | @attributes.keys keys.keep_if { |name| self[name].initialized? } end