Structure
Extend
A wrapper around a simple
[String: Any] storage dictionary used to implement Extendable.struct Extend
Overview
final cass MyType: Extendable { ... }
extension MyType {
var foo: Int {
get { return extend.get(\MyType.foo, default: 0) }
set { extend.set(\MyType.foo, to: newValue) }
}
}
Note
Extend conforms to Codable, but will yield an empty dictionary. Extensions are used for convenience and should not be encoded or decoded.
Topics
Initializers
init()Create a new extend.init(dictionaryLiteral: (String, Any)...)init(from: any Decoder) throws
Instance Properties
var storage: [String : Any]The internal storage.
Instance Methods
func encode(to: any Encoder) throwsfunc get(_:default:)Gets a value from theExtendstorage falling back to the default value if it does not exist or cannot be cast toT.func set(_:to:)Set a value to theExtendstorage.
Subscripts
subscript(String) -> Any?Allow subscripting byStringkey. This is a type-erased alternative to theget(_:default:)andset(_:to:)methods.
Relationships
Conforms To
Swift.DecodableSwift.EncodableSwift.ExpressibleByDictionaryLiteral