require "json" enum Country FR, NL, DE, IT, EI, GB, end class Address JSON.mapping( name: String, address1: String, address2: {type: String, nilable: true}, postcode: String, city: String, country: Country, is_default: {type: Bool, default: false}, ) def <=> (other : Address) self.to_json<=>other.to_json end end