You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the way the serialization mechanism is written, attributes in a serializer cannot be named either model or options, because these methods are already defined on CacheCrispies::Base. No warning or error is thrown either.
The following example demonstrates this:
#!/usr/bin/env rubyrequire"cache_crispies"classMySerializer < CacheCrispies::Basekey:my_serializerserialize:idserialize:optionsdo |model,options|
# the passed `model` will not be the model, but rather the instance# of the serializer. To retrieve the model, we have to call# `model.model`.model.model.optionsendendmodel=OpenStruct.new(id: "my_id",options: {my_option: true})putsMySerializer.new(model,{}).as_json=>{:id=>"my_id",:options=>{}}
Due to the way the serialization mechanism is written, attributes in a serializer cannot be named either
model
oroptions
, because these methods are already defined onCacheCrispies::Base
. No warning or error is thrown either.The following example demonstrates this:
The logic that exhibits this can be found on https://github.com/codenoble/cache-crispies/blob/master/lib/cache_crispies/hash_builder.rb#L63.
The text was updated successfully, but these errors were encountered: