Why
I would often like to create a Pb object from a hash object.
But a hash object does not allow dot access.
What
Add an argument to specify the access policy which uses dot access or symbol access. That uses OpenStruct internally.
e.g.
UserPbSerializer.new({
id: 1234,
name: "John Smith"
}, use_symbol_access: true)
alternatives
Wrap an object by OpenStruct before giving it to the initializer.
e.g.
UserPbSerializer.new(OpenStruct.new({
id: 1234,
name: `John Smith`,
}))
I'm using this solution temporarily, but it's a little complicated :(
Why
I would often like to create a Pb object from a hash object.
But a hash object does not allow
dot access.What
Add an argument to specify the access policy which uses
dot accessorsymbol access. That usesOpenStructinternally.e.g.
alternatives
Wrap an object by
OpenStructbefore giving it to the initializer.e.g.
I'm using this solution temporarily, but it's a little complicated :(