-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc: Introduce BaseResult to get rid of OpenStruct #3122
Conversation
Awesome! Being able to see what's expected in the result will be a tremendous help. Just thinking out loud about the syntax. How do you feel about using module AddOns
class ApplyTaxesService < BaseService
class Result < BaseResult
attribute :add_on
attribute :something, default: true
end
def call
#
end
end
end
def BaseResult
include ActiveModel::Attributes
# ...
end |
bf31362
to
1b412c3
Compare
I like the idea, but I see to problems with that:
|
e5600ca
to
642abc8
Compare
642abc8
to
0440b35
Compare
0440b35
to
53da34c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌 🙌 🙌
Context
As a requirement to enable YJIT compiler for Ruby, we need to get rid of OpenStruct as it leads to a huge memory consumption.
At the same time, we are lacking visibility on what properties are attached to result objects returned by services.
Description
This PR introduces a new
BaseResult
result object, that should be used a a base in every services to define the attributes of a Result:To keep compatibility until all services are migrated to this approach, the
BaseService
is still relying on aLegacyResult
using OpenStruct as a parent class.