Module: Sidekiq::Sorbet::InstanceMethods
- Extended by:
- T::Sig
- Defined in:
- lib/sidekiq/sorbet/instance_methods.rb
Overview
Instance methods added to workers that include Sidekiq::Sorbet
Instance Method Summary collapse
Instance Method Details
#args ⇒ Object
32 33 34 |
# File 'lib/sidekiq/sorbet/instance_methods.rb', line 32 def args @args end |
#define_arg_accessors ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sidekiq/sorbet/instance_methods.rb', line 41 def define_arg_accessors return unless @args @args.class.props.each_key do |field_name| # Skip if method already defined (avoid overriding user methods) next if respond_to?(field_name, true) && !@args.respond_to?(field_name) # Define a method to access the field define_singleton_method(field_name) do @args.public_send(field_name) end end end |
#perform(serialized_hash = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/sidekiq/sorbet/instance_methods.rb', line 19 def perform(serialized_hash = {}) @args = T.let( deserialize_args(serialized_hash), T.nilable(T::Struct), ) define_arg_accessors if @args run end |
#run ⇒ Object
60 61 62 63 |
# File 'lib/sidekiq/sorbet/instance_methods.rb', line 60 def run raise NotImplementedError, "#{self.class.name} must implement #run method" end |