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
I'm looking at using the base protobuf class and wrapping business logic around it in a separate class, using class inheritance. However, this doesn't work in this library:
require'protobuf'require'protobuf/message'moduleCorpmoduleProtobufclassError < ::Protobuf::Messagerequired:string,:foo,1endendendmoduleCorpclassErrorHandler < Corp::Protobuf::Errorendend# this worksCorp::Protobuf::Error.new(foo: :bar).encode#=> "\n\x03bar"#this does notCorp::ErrorHandler.new(foo: :bar).encode#=> ""
The root issue is within lib/protobuf/message/fields.rb and the fact that there is a somewhat hidden class instance variable @field_store and a bunch of class instance variables uses for memoization. The module doesn't define it as a class instance variable, obviously, but it extends the message class, which makes it a class instance variable.
Is this intended behavior? Do you think it is worth fixing? If so, and since active_support is already included, I think mattr_accessor will do the trick (I can submit a patch and find out :) And of course I can change my class to use the protobuf as an internal object and forgo inheritance all together.
thoughts? And thank you for the library!
The text was updated successfully, but these errors were encountered:
@skippy definitely not intended. I extracted a bunch of class-level methods from Message about a year ago and obviously didn't have a test for what you're doing. Would love to see a PR fixing it. 👍
hey folks,
I'm looking at using the base protobuf class and wrapping business logic around it in a separate class, using class inheritance. However, this doesn't work in this library:
The root issue is within
lib/protobuf/message/fields.rb
and the fact that there is a somewhat hidden class instance variable@field_store
and a bunch of class instance variables uses for memoization. The module doesn't define it as a class instance variable, obviously, but it extends the message class, which makes it a class instance variable.Is this intended behavior? Do you think it is worth fixing? If so, and since active_support is already included, I think
mattr_accessor
will do the trick (I can submit a patch and find out :) And of course I can change my class to use the protobuf as an internal object and forgo inheritance all together.thoughts? And thank you for the library!
The text was updated successfully, but these errors were encountered: