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
  def default_attribute: (String name, ?true value_present, ?Integer value) -> ActiveModel::Attribute::FromDatabase
  def fetch_value: (String name, ) -> Integer
  def initialize: (Hash values, Hash types, Hash additional_types, Hash default_attributes, ?Hash attributes, Hash attributes) -> void
  def key?: (String name) -> true
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).

def default_attribute: (String name, ?true value_present, ?Integer value) -> ActiveModel::Attribute::FromDatabase

This signature was generated using 2 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).

def fetch_value: (String name, ) -> Integer

This signature was generated using 5 samples from 1 application.

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).

def initialize: (id | Integer | name | String | path | String | drive_id | String | drive_type | String | folder_id | String | webview_url | String | connected_account_id | Integer | account_id | Integer | created_at | Time | updated_at | Time | deleted_at | NilClass | raw_data | String values, id | ActiveModel::Type::Integer | name | ActiveModel::Type::String | path | ActiveModel::Type::String | drive_id | ActiveModel::Type::String | drive_type | ActiveModel::Type::String | folder_id | ActiveModel::Type::String | webview_url | ActiveModel::Type::String | connected_account_id | ActiveModel::Type::Integer | account_id | ActiveModel::Type::Integer | created_at | ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter | updated_at | ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter | deleted_at | ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter | raw_data | ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Jsonb | webhook_id | ActiveModel::Type::String | webhook_response | ActiveModel::Type::String | google_drive_page_token | ActiveModel::Type::Integer types,  additional_types, id | ActiveModel::Attribute::FromDatabase | webhook_id | ActiveModel::Attribute::WithCastValue | webhook_response | ActiveModel::Attribute::WithCastValue | google_drive_page_token | ActiveModel::Attribute::WithCastValue default_attributes, ? attributes,  attributes) -> void

This signature was generated using 5 samples from 1 application.

:nodoc:
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) -> true

This signature was generated using 1 sample 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