-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add Tapioca compiler #533
base: main
Are you sure you want to change the base?
Add Tapioca compiler #533
Conversation
c189641
to
a80d9ea
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.
I forgot this initially - can we generate a signature for perform
as well? It'll be the same type signature as perform_now
, but an instance method, instead of a class method.
3424803
to
c76569d
Compare
end | ||
end | ||
|
||
def compile_method_parameters_to_rbi(method_def) |
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.
Do you need to copy this complex method over? I would have instead done a call to compile_method_parameters_to_rbi
and then walked over the result to find all required params of type T::Types:FixedHash
and replace them with the keyword parameters instead.
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.
I want to do that too but AFAICT the T::Types
information is not captured in the rbi types:
<RBI::TypedParam param=#<RBI::ReqParam:0x000000013295e420 @comments=[], @loc=nil, @name="params", @parent_tree=nil> type="{shop_id: ::Integer, resource_types: T::Array[::ResourceType], locale: ::Locale, metadata: T.nilable(::String)}">
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.
Right, but you can always match that data with method_types = parameters_types_from_signature(method_def, signature)
to find all required params of that type.
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.
Ah, sorry, those are also strings. I guess you could do:
signature = signature_of(method_def)
fixed_hash_args = signature.arg_types.select { |arg_type| arg_type[1].is_?(T::Types::FixedHash) }
and loop over those to match the params to the ones you need to replace.
It takes the job's `build_enumerator` method and generates the signatures for the job's corresponding `perform_later` and `perform_now` methods.
090d72e
to
fceeb76
Compare
No description provided.