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:)SeeExpressibleByDictionaryLiteral.init(from:)SeeCodable.
Instance Properties
storageThe internal storage.
Instance Methods
encode(to:)SeeCodable.get(_:default:)Gets a value from theExtendstorage falling back to the default value if it does not exist or cannot be casted toT.set(_:to:)Set a value to theExtendstorage.
Subscripts
subscript(_:)Allow subscripting byStringkey. This is a type-erased alternative to theget(_:default:)andset(:to:)methods.
Relationships
Conforms To
Swift.DecodableSwift.EncodableSwift.ExpressibleByDictionaryLiteral